1 /*
2 * matlabfindpeaks.c
3 *
4 * Code generation for function 'matlabfindpeaks'
5 *
6 */
7
8 /* Include files */
9 #include "rt_nonfinite.h"
10 #include "matlabfindpeaks.h"
11 #include "_coder_matlabfindpeaks_mex.h"
12
13 /* Type Definitions */
14 #ifndef struct_emxArray__common
15 #define struct_emxArray__common
16
17 struct emxArray__common
18 {
19 void *data;
20 int32_T *size;
21 int32_T allocatedSize;
22 int32_T numDimensions;
23 boolean_T canFreeData;
24 };
25
26 #endif /*struct_emxArray__common*/
27
28 #ifndef typedef_emxArray__common
29 #define typedef_emxArray__common
30
31 typedef struct emxArray__common emxArray__common;
32
33 #endif /*typedef_emxArray__common*/
34
35 #ifndef struct_emxArray_boolean_T
36 #define struct_emxArray_boolean_T
37
38 struct emxArray_boolean_T
39 {
40 boolean_T *data;
41 int32_T *size;
42 int32_T allocatedSize;
43 int32_T numDimensions;
44 boolean_T canFreeData;
45 };
46
47 #endif /*struct_emxArray_boolean_T*/
48
49 #ifndef typedef_emxArray_boolean_T
50 #define typedef_emxArray_boolean_T
51
52 typedef struct emxArray_boolean_T emxArray_boolean_T;
53
54 #endif /*typedef_emxArray_boolean_T*/
55
56 #ifndef struct_emxArray_int32_T
57 #define struct_emxArray_int32_T
58
59 struct emxArray_int32_T
60 {
61 int32_T *data;
62 int32_T *size;
63 int32_T allocatedSize;
64 int32_T numDimensions;
65 boolean_T canFreeData;
66 };
67
68 #endif /*struct_emxArray_int32_T*/
69
70 #ifndef typedef_emxArray_int32_T
71 #define typedef_emxArray_int32_T
72
73 typedef struct emxArray_int32_T emxArray_int32_T;
74
75 #endif /*typedef_emxArray_int32_T*/
76
77 /* Variable Definitions */
78 emlrtCTX emlrtRootTLSGlobal = NULL;
79 const volatile char_T *emlrtBreakCheckR2012bFlagVar = NULL;
80 static covrtInstance emlrtCoverageInstance;
81 emlrtContext emlrtContextGlobal = { true, false, 131434U, NULL,
82 "matlabfindpeaks", NULL, false, { 2045744189U, 2170104910U, 2743257031U,
83 4284093946U }, NULL };
84
85 static emlrtRSInfo emlrtRSI = { 3, "matlabfindpeaks",
86 "C:\\\\Users\\\\86188\\\\Desktop\\\\\xe5\xaf\xbb\xe5\xb3\xb0\xe7\xae\x97\xe6\xb3\x95\\\\matlabfindpeaks.m"
87 };
88
89 static emlrtRSInfo b_emlrtRSI = { 133, "findpeaks",
90 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
91
92 static emlrtRSInfo c_emlrtRSI = { 137, "findpeaks",
93 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
94
95 static emlrtRSInfo d_emlrtRSI = { 141, "findpeaks",
96 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
97
98 static emlrtRSInfo e_emlrtRSI = { 142, "findpeaks",
99 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
100
101 static emlrtRSInfo f_emlrtRSI = { 154, "findpeaks",
102 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
103
104 static emlrtRSInfo g_emlrtRSI = { 158, "findpeaks",
105 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
106
107 static emlrtRSInfo h_emlrtRSI = { 162, "findpeaks",
108 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
109
110 static emlrtRSInfo i_emlrtRSI = { 175, "findpeaks",
111 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
112
113 static emlrtRSInfo j_emlrtRSI = { 330, "findpeaks",
114 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
115
116 static emlrtRSInfo k_emlrtRSI = { 352, "findpeaks",
117 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
118
119 static emlrtRSInfo l_emlrtRSI = { 363, "findpeaks",
120 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
121
122 static emlrtRSInfo m_emlrtRSI = { 370, "findpeaks",
123 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
124
125 static emlrtRSInfo n_emlrtRSI = { 44, "find",
126 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elmat\\find.m" };
127
128 static emlrtRSInfo o_emlrtRSI = { 253, "find",
129 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elmat\\find.m" };
130
131 static emlrtRSInfo p_emlrtRSI = { 18, "indexShapeCheck",
132 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\indexShapeCheck.m" };
133
134 static emlrtRSInfo q_emlrtRSI = { 381, "findpeaks",
135 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
136
137 static emlrtRSInfo r_emlrtRSI = { 386, "findpeaks",
138 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
139
140 static emlrtRSInfo s_emlrtRSI = { 389, "findpeaks",
141 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
142
143 static emlrtRSInfo t_emlrtRSI = { 392, "findpeaks",
144 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
145
146 emlrtRSInfo u_emlrtRSI = { 108, "diff",
147 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\diff.m" };
148
149 emlrtRSInfo v_emlrtRSI = { 106, "diff",
150 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\diff.m" };
151
152 static emlrtRSInfo w_emlrtRSI = { 20, "eml_int_forloop_overflow_check",
153 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\eml\\eml_int_forloop_overflow_check.m"
154 };
155
156 emlrtRSInfo x_emlrtRSI = { 13, "sign",
157 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elfun\\sign.m" };
158
159 emlrtRSInfo y_emlrtRSI = { 24, "applyScalarFunctionInPlace",
160 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\applyScalarFunctionInPlace.m"
161 };
162
163 emlrtRSInfo ab_emlrtRSI = { 234, "find",
164 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elmat\\find.m" };
165
166 static emlrtRSInfo bb_emlrtRSI = { 412, "findpeaks",
167 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
168
169 static emlrtRSInfo cb_emlrtRSI = { 13, "max",
170 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\max.m" };
171
172 static emlrtRSInfo db_emlrtRSI = { 19, "minOrMax",
173 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\minOrMax.m" };
174
175 static emlrtRSInfo eb_emlrtRSI = { 81, "minOrMax",
176 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\minOrMax.m" };
177
178 static emlrtRSInfo fb_emlrtRSI = { 243, "minOrMax",
179 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\minOrMax.m" };
180
181 static emlrtRSInfo gb_emlrtRSI = { 269, "minOrMax",
182 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\minOrMax.m" };
183
184 static emlrtRSInfo hb_emlrtRSI = { 657, "findpeaks",
185 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
186
187 static emlrtRSInfo ib_emlrtRSI = { 23, "union",
188 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\union.m" };
189
190 static emlrtRSInfo jb_emlrtRSI = { 70, "eml_setop",
191 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
192
193 emlrtRSInfo kb_emlrtRSI = { 224, "eml_setop",
194 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
195
196 static emlrtRSInfo lb_emlrtRSI = { 225, "eml_setop",
197 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
198
199 emlrtRSInfo mb_emlrtRSI = { 227, "eml_setop",
200 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
201
202 static emlrtRSInfo nb_emlrtRSI = { 228, "eml_setop",
203 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
204
205 emlrtRSInfo ob_emlrtRSI = { 28, "issorted",
206 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\issorted.m" };
207
208 static emlrtRSInfo pb_emlrtRSI = { 729, "findpeaks",
209 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
210
211 static emlrtRSInfo qb_emlrtRSI = { 738, "findpeaks",
212 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
213
214 static emlrtRSInfo rb_emlrtRSI = { 752, "findpeaks",
215 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
216
217 static emlrtRSInfo sb_emlrtRSI = { 21, "colon",
218 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
219
220 static emlrtRSInfo tb_emlrtRSI = { 79, "colon",
221 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
222
223 emlrtRSInfo ub_emlrtRSI = { 283, "colon",
224 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
225
226 emlrtRSInfo vb_emlrtRSI = { 291, "colon",
227 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\colon.m" };
228
229 static emlrtRSInfo wb_emlrtRSI = { 26, "sort",
230 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\sort.m" };
231
232 static emlrtRSInfo xb_emlrtRSI = { 19, "sort",
233 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
234
235 static emlrtRSInfo yb_emlrtRSI = { 48, "sort",
236 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
237
238 static emlrtRSInfo ac_emlrtRSI = { 69, "sort",
239 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
240
241 static emlrtRSInfo bc_emlrtRSI = { 72, "sort",
242 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
243
244 static emlrtRSInfo cc_emlrtRSI = { 74, "sort",
245 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
246
247 static emlrtRSInfo dc_emlrtRSI = { 77, "sort",
248 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
249
250 static emlrtRSInfo ec_emlrtRSI = { 80, "sort",
251 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
252
253 static emlrtRSInfo fc_emlrtRSI = { 82, "sort",
254 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
255
256 static emlrtRSInfo gc_emlrtRSI = { 49, "prodsize",
257 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\prodsize.m" };
258
259 static emlrtRSInfo hc_emlrtRSI = { 70, "sortIdx",
260 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
261
262 static emlrtRSInfo ic_emlrtRSI = { 331, "sortIdx",
263 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
264
265 static emlrtRSInfo jc_emlrtRSI = { 339, "sortIdx",
266 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
267
268 static emlrtRSInfo kc_emlrtRSI = { 340, "sortIdx",
269 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
270
271 static emlrtRSInfo lc_emlrtRSI = { 348, "sortIdx",
272 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
273
274 static emlrtRSInfo mc_emlrtRSI = { 356, "sortIdx",
275 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
276
277 static emlrtRSInfo nc_emlrtRSI = { 361, "sortIdx",
278 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
279
280 static emlrtRSInfo oc_emlrtRSI = { 413, "sortIdx",
281 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
282
283 static emlrtRSInfo pc_emlrtRSI = { 441, "sortIdx",
284 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
285
286 static emlrtRSInfo qc_emlrtRSI = { 448, "sortIdx",
287 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
288
289 emlrtRSInfo rc_emlrtRSI = { 608, "sortIdx",
290 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
291
292 emlrtRSInfo sc_emlrtRSI = { 610, "sortIdx",
293 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
294
295 emlrtRSInfo tc_emlrtRSI = { 638, "sortIdx",
296 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
297
298 static emlrtRSInfo uc_emlrtRSI = { 520, "sortIdx",
299 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
300
301 emlrtRSInfo vc_emlrtRSI = { 527, "sortIdx",
302 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
303
304 static emlrtRSInfo wc_emlrtRSI = { 528, "sortIdx",
305 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
306
307 static emlrtRSInfo xc_emlrtRSI = { 535, "sortIdx",
308 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
309
310 static emlrtRSInfo yc_emlrtRSI = { 582, "sortIdx",
311 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
312
313 static emlrtRSInfo ad_emlrtRSI = { 551, "sortIdx",
314 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
315
316 static emlrtRSInfo bd_emlrtRSI = { 375, "sortIdx",
317 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
318
319 static emlrtRSInfo cd_emlrtRSI = { 384, "sortIdx",
320 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
321
322 static emlrtRSInfo dd_emlrtRSI = { 31, "sort",
323 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\sort.m" };
324
325 static emlrtRSInfo ed_emlrtRSI = { 776, "findpeaks",
326 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
327
328 static emlrtRTEInfo emlrtRTEI = { 1, 30, "findpeaks",
329 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
330
331 static emlrtRTEInfo b_emlrtRTEI = { 141, 1, "findpeaks",
332 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
333
334 static emlrtRTEInfo c_emlrtRTEI = { 361, 32, "findpeaks",
335 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
336
337 static emlrtRTEInfo d_emlrtRTEI = { 36, 6, "find",
338 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elmat\\find.m" };
339
340 static emlrtRTEInfo e_emlrtRTEI = { 50, 20, "find",
341 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elmat\\find.m" };
342
343 static emlrtRTEInfo f_emlrtRTEI = { 253, 13, "find",
344 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elmat\\find.m" };
345
346 static emlrtRTEInfo g_emlrtRTEI = { 374, 28, "findpeaks",
347 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
348
349 static emlrtRTEInfo h_emlrtRTEI = { 381, 1, "findpeaks",
350 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
351
352 static emlrtRTEInfo i_emlrtRTEI = { 386, 1, "findpeaks",
353 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
354
355 static emlrtRTEInfo j_emlrtRTEI = { 377, 1, "findpeaks",
356 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
357
358 static emlrtRTEInfo k_emlrtRTEI = { 1, 14, "diff",
359 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\diff.m" };
360
361 static emlrtRTEInfo l_emlrtRTEI = { 399, 16, "findpeaks",
362 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
363
364 static emlrtRTEInfo m_emlrtRTEI = { 410, 16, "findpeaks",
365 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
366
367 static emlrtRTEInfo n_emlrtRTEI = { 656, 40, "findpeaks",
368 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
369
370 static emlrtRTEInfo o_emlrtRTEI = { 134, 22, "eml_setop",
371 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
372
373 static emlrtRTEInfo p_emlrtRTEI = { 724, 16, "findpeaks",
374 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
375
376 static emlrtRTEInfo q_emlrtRTEI = { 735, 1, "findpeaks",
377 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
378
379 static emlrtRTEInfo r_emlrtRTEI = { 739, 1, "findpeaks",
380 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
381
382 static emlrtRTEInfo s_emlrtRTEI = { 741, 1, "findpeaks",
383 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
384
385 static emlrtRTEInfo t_emlrtRTEI = { 1, 20, "sort",
386 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
387
388 static emlrtRTEInfo u_emlrtRTEI = { 1, 20, "sortIdx",
389 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
390
391 static emlrtRTEInfo v_emlrtRTEI = { 773, 16, "findpeaks",
392 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
393
394 static emlrtRTEInfo w_emlrtRTEI = { 787, 28, "findpeaks",
395 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
396
397 static emlrtRTEInfo x_emlrtRTEI = { 1, 1, "_coder_matlabfindpeaks_api", "" };
398
399 static emlrtRTEInfo y_emlrtRTEI = { 16, 9, "scalexpAlloc",
400 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\scalexpAlloc.m" };
401
402 static emlrtRTEInfo ab_emlrtRTEI = { 412, 1, "findpeaks",
403 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
404
405 static emlrtRTEInfo bb_emlrtRTEI = { 50, 1, "sort",
406 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sort.m" };
407
408 static emlrtRTEInfo cb_emlrtRTEI = { 406, 9, "sortIdx",
409 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
410
411 static emlrtRTEInfo db_emlrtRTEI = { 408, 9, "sortIdx",
412 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
413
414 static emlrtRTEInfo eb_emlrtRTEI = { 331, 14, "sortIdx",
415 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
416
417 static emlrtRTEInfo fb_emlrtRTEI = { 331, 20, "sortIdx",
418 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\sortIdx.m" };
419
420 static emlrtDCInfo emlrtDCI = { 165, 7, "findpeaks",
421 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 1 };
422
423 static emlrtBCInfo emlrtBCI = { -1, -1, 165, 7, "", "findpeaks",
424 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
425
426 static emlrtBCInfo b_emlrtBCI = { 1, 52000, 367, 1, "", "findpeaks",
427 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
428
429 static emlrtRTEInfo gb_emlrtRTEI = { 88, 9, "indexShapeCheck",
430 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\indexShapeCheck.m" };
431
432 static emlrtBCInfo c_emlrtBCI = { -1, -1, 392, 17, "", "findpeaks",
433 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
434
435 static emlrtBCInfo d_emlrtBCI = { -1, -1, 392, 29, "", "findpeaks",
436 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
437
438 static emlrtECInfo emlrtECI = { -1, 392, 17, "findpeaks",
439 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
440
441 static emlrtBCInfo e_emlrtBCI = { -1, -1, 395, 12, "", "findpeaks",
442 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
443
444 static emlrtBCInfo f_emlrtBCI = { -1, -1, 396, 7, "", "findpeaks",
445 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
446
447 static emlrtRTEInfo hb_emlrtRTEI = { 51, 19, "diff",
448 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\datafun\\diff.m" };
449
450 static emlrtRTEInfo ib_emlrtRTEI = { 86, 15, "eml_int_forloop_overflow_check",
451 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\eml\\eml_int_forloop_overflow_check.m"
452 };
453
454 static emlrtRTEInfo jb_emlrtRTEI = { 243, 9, "find",
455 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\elmat\\find.m" };
456
457 static emlrtRTEInfo kb_emlrtRTEI = { 392, 5, "eml_setop",
458 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
459
460 static emlrtRTEInfo lb_emlrtRTEI = { 403, 9, "eml_setop",
461 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
462
463 static emlrtRTEInfo mb_emlrtRTEI = { 430, 5, "eml_setop",
464 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\ops\\private\\eml_setop.m" };
465
466 static emlrtRTEInfo nb_emlrtRTEI = { 17, 9, "error",
467 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\error.m" };
468
469 static emlrtECInfo b_emlrtECI = { -1, 746, 15, "findpeaks",
470 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
471
472 static emlrtECInfo c_emlrtECI = { -1, 746, 25, "findpeaks",
473 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
474
475 static emlrtBCInfo g_emlrtBCI = { 1, 52000, 734, 7, "", "findpeaks",
476 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
477
478 static emlrtBCInfo h_emlrtBCI = { -1, -1, 739, 13, "", "findpeaks",
479 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
480
481 static emlrtBCInfo i_emlrtBCI = { -1, -1, 752, 12, "", "findpeaks",
482 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
483
484 static emlrtBCInfo j_emlrtBCI = { -1, -1, 743, 7, "", "findpeaks",
485 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
486
487 static emlrtBCInfo k_emlrtBCI = { -1, -1, 746, 37, "", "findpeaks",
488 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
489
490 static emlrtBCInfo l_emlrtBCI = { -1, -1, 746, 66, "", "findpeaks",
491 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
492
493 static emlrtBCInfo m_emlrtBCI = { -1, -1, 747, 5, "", "findpeaks",
494 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
495
496 static emlrtBCInfo n_emlrtBCI = { 1, 52000, 790, 7, "", "findpeaks",
497 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
498
499 static emlrtRTEInfo ob_emlrtRTEI = { 157, 28, "validateattributes",
500 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\lang\\validateattributes.m" };
501
502 static emlrtRTEInfo pb_emlrtRTEI = { 271, 28, "validateattributes",
503 "D:\\Matlab\\toolbox\\eml\\lib\\matlab\\lang\\validateattributes.m" };
504
505 static emlrtBCInfo o_emlrtBCI = { 1, 52000, 401, 13, "", "findpeaks",
506 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
507
508 static emlrtBCInfo p_emlrtBCI = { -1, -1, 401, 9, "", "findpeaks",
509 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
510
511 static emlrtRTEInfo qb_emlrtRTEI = { 17, 19, "scalexpAlloc",
512 "D:\\Matlab\\toolbox\\eml\\eml\\+coder\\+internal\\scalexpAlloc.m" };
513
514 static emlrtECInfo d_emlrtECI = { -1, 413, 11, "findpeaks",
515 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m" };
516
517 static emlrtBCInfo q_emlrtBCI = { 1, 52000, 412, 12, "", "findpeaks",
518 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
519
520 static emlrtBCInfo r_emlrtBCI = { 1, 52000, 412, 21, "", "findpeaks",
521 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
522
523 static emlrtBCInfo s_emlrtBCI = { 1, 52000, 413, 11, "", "findpeaks",
524 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
525
526 static emlrtBCInfo t_emlrtBCI = { -1, -1, 413, 7, "", "findpeaks",
527 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
528
529 static emlrtBCInfo u_emlrtBCI = { -1, -1, 776, 9, "", "findpeaks",
530 "D:\\Matlab\\toolbox\\signal\\signal\\findpeaks.m", 0 };
531
532 /* Function Declarations */
533 static void assertValidDim(void);
534 static void assignOutputs(const emlrtStack *sp, const real_T y[52000], const
535 real_T x[52000], const emxArray_real_T *iPk, emxArray_real_T *YpkOut,
536 emxArray_real_T *XpkOut);
537 static void b_eml_find(const emlrtStack *sp, const boolean_T x[52001],
538 emxArray_int32_T *i);
539 static real_T (*b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
540 emlrtMsgIdentifier *parentId))[52000];
541 static void b_error(const emlrtStack *sp);
542 static void b_merge(const emlrtStack *sp, emxArray_int32_T *idx, emxArray_real_T
543 *x, int32_T offset, int32_T np, int32_T nq, emxArray_int32_T
544 *iwork, emxArray_real_T *xwork);
545 static void b_merge_block(const emlrtStack *sp, emxArray_int32_T *idx,
546 emxArray_real_T *x, int32_T offset, int32_T n, int32_T preSortLevel,
547 emxArray_int32_T *iwork, emxArray_real_T *xwork);
548 static void b_merge_pow2_block(emxArray_int32_T *idx, emxArray_real_T *x,
549 int32_T offset);
550 static void b_sign(emxArray_real_T *x);
551 static void b_sort(const emlrtStack *sp, emxArray_real_T *x, int32_T dim,
552 emxArray_int32_T *idx);
553 static void b_sortIdx(const emlrtStack *sp, emxArray_real_T *x, emxArray_int32_T
554 *idx);
555 static void c_eml_find(const emlrtStack *sp, const boolean_T x_data[], const
556 int32_T x_size[1], emxArray_int32_T *i);
557 static real_T c_emlrt_marshallIn(const emlrtStack *sp, const mxArray
558 *minpeakhight, const char_T *identifier);
559 static void c_findPeaksSeparatedByMoreThanM(const emlrtStack *sp, const real_T
560 y[52000], const emxArray_real_T *iPk, int32_T Pd, emxArray_real_T *idx);
561 static void c_sort(const emlrtStack *sp, emxArray_real_T *x);
562 static void check_forloop_overflow_error(const emlrtStack *sp);
563 static void combinePeaks(const emlrtStack *sp, const emxArray_real_T *iPk, const
564 emxArray_real_T *iInf, emxArray_real_T *iPkOut);
565 static real_T d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
566 emlrtMsgIdentifier *parentId);
567 static void diff(const emlrtStack *sp, const emxArray_real_T *x, emxArray_real_T
568 *y);
569 static boolean_T dimagree(const emxArray_real_T *z, const emxArray_real_T
570 *varargin_1, const emxArray_real_T *varargin_2);
571 static void do_vectors(const emlrtStack *sp, const emxArray_real_T *a, const
572 emxArray_real_T *b, emxArray_real_T *c, emxArray_int32_T *ia, emxArray_int32_T
573 *ib);
574 static int32_T e_emlrt_marshallIn(const emlrtStack *sp, const mxArray
575 *minpeakdistance, const char_T *identifier);
576 static void eml_find(const emlrtStack *sp, const boolean_T x[52000],
577 emxArray_int32_T *i);
578 static real_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *Yin, const
579 char_T *identifier))[52000];
580 static const mxArray *emlrt_marshallOut(const emxArray_real_T *u);
581 static void emxEnsureCapacity(const emlrtStack *sp, emxArray__common *emxArray,
582 int32_T oldNumel, int32_T elementSize, const emlrtRTEInfo *srcLocation);
583 static void emxFree_boolean_T(emxArray_boolean_T **pEmxArray);
584 static void emxFree_int32_T(emxArray_int32_T **pEmxArray);
585 static void emxFree_real_T(emxArray_real_T **pEmxArray);
586 static void emxInit_boolean_T(const emlrtStack *sp, emxArray_boolean_T
587 **pEmxArray, int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T
588 doPush);
589 static void emxInit_int32_T(const emlrtStack *sp, emxArray_int32_T **pEmxArray,
590 int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T doPush);
591 static void emxInit_real_T(const emlrtStack *sp, emxArray_real_T **pEmxArray,
592 int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T doPush);
593 static void emxInit_real_T1(const emlrtStack *sp, emxArray_real_T **pEmxArray,
594 int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T doPush);
595 static void error(const emlrtStack *sp);
596 static int32_T f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
597 emlrtMsgIdentifier *parentId);
598 static void findLocalMaxima(matlabfindpeaksStackData *SD, const emlrtStack *sp,
599 const real_T yTemp[52000], emxArray_real_T *iPk, emxArray_real_T *iInflect);
600 static void findpeaks(matlabfindpeaksStackData *SD, const emlrtStack *sp, const
601 real_T Yin[52000], real_T varargin_2, int32_T varargin_4,
602 emxArray_real_T *Ypk, emxArray_real_T *Xpk);
603 static real_T (*g_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
604 const emlrtMsgIdentifier *msgId))[52000];
605 static void getAllPeaks(matlabfindpeaksStackData *SD, const emlrtStack *sp,
606 const real_T y[52000], emxArray_real_T *iPk, emxArray_real_T *iInf,
607 emxArray_real_T *iInflect);
608 static real_T h_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
609 emlrtMsgIdentifier *msgId);
610 static int32_T i_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
611 const emlrtMsgIdentifier *msgId);
612 static void indexShapeCheck(const emlrtStack *sp, int32_T matrixSize, const
613 int32_T indexSize[2]);
614 static boolean_T issorted(const emxArray_real_T *x);
615 static void keepAtMostNpPeaks(const emlrtStack *sp, emxArray_real_T *idx);
616 static void matlabfindpeaks_once(void);
617 static void merge(const emlrtStack *sp, emxArray_int32_T *idx, emxArray_real_T
618 *x, int32_T offset, int32_T np, int32_T nq, emxArray_int32_T
619 *iwork, emxArray_real_T *xwork);
620 static void merge_block(const emlrtStack *sp, emxArray_int32_T *idx,
621 emxArray_real_T *x, int32_T offset, int32_T n, int32_T preSortLevel,
622 emxArray_int32_T *iwork, emxArray_real_T *xwork);
623 static void merge_pow2_block(emxArray_int32_T *idx, emxArray_real_T *x, int32_T
624 offset);
625 static int32_T nonSingletonDim(const emxArray_real_T *x);
626 static void parse_inputs(const emlrtStack *sp, real_T varargin_2, int32_T
627 varargin_4, real_T *Ph, int32_T *Pd);
628 static void removePeaksBelowMinPeakHeight(const emlrtStack *sp, const real_T Y
629 [52000], emxArray_real_T *iPk, real_T Ph);
630 static void removePeaksBelowThreshold(const emlrtStack *sp, const real_T Y[52000],
631 emxArray_real_T *iPk);
632 static real_T skip_to_last_equal_value(int32_T *k, const emxArray_real_T *x);
633 static void sort(const emlrtStack *sp, emxArray_real_T *x, emxArray_int32_T *idx);
634 static void sortIdx(const emlrtStack *sp, emxArray_real_T *x, emxArray_int32_T
635 *idx);
636
637 /* Function Definitions */
638 static void assertValidDim(void)
639 {
640 }
641
642 static void assignOutputs(const emlrtStack *sp, const real_T y[52000], const
643 real_T x[52000], const emxArray_real_T *iPk, emxArray_real_T *YpkOut,
644 emxArray_real_T *XpkOut)
645 {
646 int32_T loop_ub;
647 int32_T i11;
648 int32_T i12;
649 loop_ub = iPk->size[0];
650 for (i11 = 0; i11 < loop_ub; i11++) {
651 i12 = (int32_T)iPk->data[i11];
652 if (!((i12 >= 1) && (i12 <= 52000))) {
653 emlrtDynamicBoundsCheckR2012b(i12, 1, 52000, &n_emlrtBCI, sp);
654 }
655 }
656
657 i11 = YpkOut->size[0];
658 YpkOut->size[0] = iPk->size[0];
659 emxEnsureCapacity(sp, (emxArray__common *)YpkOut, i11, (int32_T)sizeof(real_T),
660 &w_emlrtRTEI);
661 loop_ub = iPk->size[0];
662 for (i11 = 0; i11 < loop_ub; i11++) {
663 YpkOut->data[i11] = y[(int32_T)iPk->data[i11] - 1];
664 }
665
666 i11 = XpkOut->size[0];
667 XpkOut->size[0] = iPk->size[0];
668 emxEnsureCapacity(sp, (emxArray__common *)XpkOut, i11, (int32_T)sizeof(real_T),
669 &w_emlrtRTEI);
670 loop_ub = iPk->size[0];
671 for (i11 = 0; i11 < loop_ub; i11++) {
672 XpkOut->data[i11] = x[(int32_T)iPk->data[i11] - 1];
673 }
674 }
675
676 static void b_eml_find(const emlrtStack *sp, const boolean_T x[52001],
677 emxArray_int32_T *i)
678 {
679 int32_T idx;
680 int32_T i6;
681 int32_T ii;
682 boolean_T exitg1;
683 boolean_T guard1 = false;
684 int32_T iv3[2];
685 emlrtStack st;
686 st.prev = sp;
687 st.tls = sp->tls;
688 idx = 0;
689 i6 = i->size[0];
690 i->size[0] = 52001;
691 emxEnsureCapacity(sp, (emxArray__common *)i, i6, (int32_T)sizeof(int32_T),
692 &e_emlrtRTEI);
693 ii = 1;
694 exitg1 = false;
695 while ((!exitg1) && (ii < 52002)) {
696 guard1 = false;
697 if (x[ii - 1]) {
698 idx++;
699 i->data[idx - 1] = ii;
700 if (idx >= 52001) {
701 exitg1 = true;
702 } else {
703 guard1 = true;
704 }
705 } else {
706 guard1 = true;
707 }
708
709 if (guard1) {
710 ii++;
711 }
712 }
713
714 if (1 > idx) {
715 i6 = 0;
716 } else {
717 i6 = idx;
718 }
719
720 iv3[0] = 1;
721 iv3[1] = i6;
722 st.site = &o_emlrtRSI;
723 indexShapeCheck(&st, 52001, iv3);
724 ii = i->size[0];
725 i->size[0] = i6;
726 emxEnsureCapacity(sp, (emxArray__common *)i, ii, (int32_T)sizeof(int32_T),
727 &f_emlrtRTEI);
728 }
729
730 static real_T (*b_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
731 emlrtMsgIdentifier *parentId))[52000]
732 {
733 real_T (*y)[52000];
734 y = g_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
735 emlrtDestroyArray(&u);
736 return y;
737 }
738 static void b_error(const emlrtStack *sp)
739 {
740 emlrtErrorWithMessageIdR2012b(sp, &nb_emlrtRTEI,
741 "Coder:toolbox:eml_setop_unsortedB", 0);
742 }
743
744 static void b_merge(const emlrtStack *sp, emxArray_int32_T *idx, emxArray_real_T
745 *x, int32_T offset, int32_T np, int32_T nq, emxArray_int32_T
746 *iwork, emxArray_real_T *xwork)
747 {
748 int32_T n;
749 int32_T qend;
750 int32_T p;
751 int32_T iout;
752 int32_T exitg1;
753 emlrtStack st;
754 emlrtStack b_st;
755 st.prev = sp;
756 st.tls = sp->tls;
757 b_st.prev = &st;
758 b_st.tls = st.tls;
759 if (nq == 0) {
760 } else {
761 n = np + nq;
762 st.site = &ad_emlrtRSI;
763 if ((!(1 > n)) && (n > 2147483646)) {
764 b_st.site = &w_emlrtRSI;
765 check_forloop_overflow_error(&b_st);
766 }
767
768 for (qend = 0; qend + 1 <= n; qend++) {
769 iwork->data[qend] = idx->data[offset + qend];
770 xwork->data[qend] = x->data[offset + qend];
771 }
772
773 p = 0;
774 n = np;
775 qend = np + nq;
776 iout = offset - 1;
777 do {
778 exitg1 = 0;
779 iout++;
780 if (xwork->data[p] <= xwork->data[n]) {
781 idx->data[iout] = iwork->data[p];
782 x->data[iout] = xwork->data[p];
783 if (p + 1 < np) {
784 p++;
785 } else {
786 exitg1 = 1;
787 }
788 } else {
789 idx->data[iout] = iwork->data[n];
790 x->data[iout] = xwork->data[n];
791 if (n + 1 < qend) {
792 n++;
793 } else {
794 n = (iout - p) + 1;
795 st.site = &yc_emlrtRSI;
796 if ((!(p + 1 > np)) && (np > 2147483646)) {
797 b_st.site = &w_emlrtRSI;
798 check_forloop_overflow_error(&b_st);
799 }
800
801 while (p + 1 <= np) {
802 idx->data[n + p] = iwork->data[p];
803 x->data[n + p] = xwork->data[p];
804 p++;
805 }
806
807 exitg1 = 1;
808 }
809 }
810 } while (exitg1 == 0);
811 }
812 }
813
814 static void b_merge_block(const emlrtStack *sp, emxArray_int32_T *idx,
815 emxArray_real_T *x, int32_T offset, int32_T n, int32_T preSortLevel,
816 emxArray_int32_T *iwork, emxArray_real_T *xwork)
817 {
818 int32_T nPairs;
819 int32_T bLen;
820 int32_T tailOffset;
821 int32_T nTail;
822 emlrtStack st;
823 st.prev = sp;
824 st.tls = sp->tls;
825 nPairs = n >> preSortLevel;
826 bLen = 1 << preSortLevel;
827 while (nPairs > 1) {
828 if ((nPairs & 1) != 0) {
829 nPairs--;
830 tailOffset = bLen * nPairs;
831 nTail = n - tailOffset;
832 if (nTail > bLen) {
833 st.site = &uc_emlrtRSI;
834 b_merge(&st, idx, x, offset + tailOffset, bLen, nTail - bLen, iwork,
835 xwork);
836 }
837 }
838
839 tailOffset = bLen << 1;
840 nPairs >>= 1;
841 for (nTail = 1; nTail <= nPairs; nTail++) {
842 st.site = &wc_emlrtRSI;
843 b_merge(&st, idx, x, offset + (nTail - 1) * tailOffset, bLen, bLen, iwork,
844 xwork);
845 }
846
847 bLen = tailOffset;
848 }
849
850 if (n > bLen) {
851 st.site = &xc_emlrtRSI;
852 b_merge(&st, idx, x, offset, bLen, n - bLen, iwork, xwork);
853 }
854 }
855
856 static void b_merge_pow2_block(emxArray_int32_T *idx, emxArray_real_T *x,
857 int32_T offset)
858 {
859 int32_T iwork[256];
860 real_T xwork[256];
861 int32_T b;
862 int32_T bLen;
863 int32_T bLen2;
864 int32_T nPairs;
865 int32_T k;
866 int32_T blockOffset;
867 int32_T iout;
868 int32_T p;
869 int32_T q;
870 int32_T exitg1;
871 for (b = 0; b < 6; b++) {
872 bLen = 1 << (b + 2);
873 bLen2 = bLen << 1;
874 nPairs = 256 >> (b + 3);
875 for (k = 1; k <= nPairs; k++) {
876 blockOffset = offset + (k - 1) * bLen2;
877 for (iout = 0; iout + 1 <= bLen2; iout++) {
878 iwork[iout] = idx->data[blockOffset + iout];
879 xwork[iout] = x->data[blockOffset + iout];
880 }
881
882 p = 0;
883 q = bLen;
884 iout = blockOffset - 1;
885 do {
886 exitg1 = 0;
887 iout++;
888 if (xwork[p] <= xwork[q]) {
889 idx->data[iout] = iwork[p];
890 x->data[iout] = xwork[p];
891 if (p + 1 < bLen) {
892 p++;
893 } else {
894 exitg1 = 1;
895 }
896 } else {
897 idx->data[iout] = iwork[q];
898 x->data[iout] = xwork[q];
899 if (q + 1 < bLen2) {
900 q++;
901 } else {
902 iout = (iout - p) + 1;
903 while (p + 1 <= bLen) {
904 idx->data[iout + p] = iwork[p];
905 x->data[iout + p] = xwork[p];
906 p++;
907 }
908
909 exitg1 = 1;
910 }
911 }
912 } while (exitg1 == 0);
913 }
914 }
915 }
916
917 static void b_sign(emxArray_real_T *x)
918 {
919 int32_T nx;
920 int32_T k;
921 nx = x->size[0];
922 for (k = 0; k + 1 <= nx; k++) {
923 x->data[k] = muDoubleScalarSign(x->data[k]);
924 }
925 }
926
927 static void b_sort(const emlrtStack *sp, emxArray_real_T *x, int32_T dim,
928 emxArray_int32_T *idx)
929 {
930 int32_T i16;
931 emxArray_real_T *vwork;
932 int32_T vstride;
933 int32_T x_idx_0;
934 int32_T j;
935 emxArray_int32_T *iidx;
936 emlrtStack st;
937 emlrtStack b_st;
938 emlrtStack c_st;
939 st.prev = sp;
940 st.tls = sp->tls;
941 b_st.prev = &st;
942 b_st.tls = st.tls;
943 c_st.prev = &b_st;
944 c_st.tls = b_st.tls;
945 emlrtHeapReferenceStackEnterFcnR2012b(sp);
946 st.site = &yb_emlrtRSI;
947 assertValidDim();
948 if (dim <= 1) {
949 i16 = x->size[0];
950 } else {
951 i16 = 1;
952 }
953
954 emxInit_real_T(sp, &vwork, 1, &bb_emlrtRTEI, true);
955 vstride = vwork->size[0];
956 vwork->size[0] = i16;
957 emxEnsureCapacity(sp, (emxArray__common *)vwork, vstride, (int32_T)sizeof
958 (real_T), &t_emlrtRTEI);
959 x_idx_0 = x->size[0];
960 vstride = idx->size[0];
961 idx->size[0] = x_idx_0;
962 emxEnsureCapacity(sp, (emxArray__common *)idx, vstride, (int32_T)sizeof
963 (int32_T), &t_emlrtRTEI);
964 st.site = &ac_emlrtRSI;
965 vstride = 1;
966 b_st.site = &gc_emlrtRSI;
967 if ((!(1 > dim - 1)) && (dim - 1 > 2147483646)) {
968 c_st.site = &w_emlrtRSI;
969 check_forloop_overflow_error(&c_st);
970 }
971
972 x_idx_0 = 1;
973 while (x_idx_0 <= dim - 1) {
974 vstride *= x->size[0];
975 x_idx_0 = 2;
976 }
977
978 st.site = &bc_emlrtRSI;
979 st.site = &cc_emlrtRSI;
980 if ((!(1 > vstride)) && (vstride > 2147483646)) {
981 b_st.site = &w_emlrtRSI;
982 check_forloop_overflow_error(&b_st);
983 }
984
985 j = 0;
986 emxInit_int32_T(sp, &iidx, 1, &t_emlrtRTEI, true);
987 while (j + 1 <= vstride) {
988 st.site = &dc_emlrtRSI;
989 for (x_idx_0 = 0; x_idx_0 + 1 <= i16; x_idx_0++) {
990 vwork->data[x_idx_0] = x->data[j + x_idx_0 * vstride];
991 }
992
993 st.site = &ec_emlrtRSI;
994 sortIdx(&st, vwork, iidx);
995 st.site = &fc_emlrtRSI;
996 for (x_idx_0 = 0; x_idx_0 + 1 <= i16; x_idx_0++) {
997 x->data[j + x_idx_0 * vstride] = vwork->data[x_idx_0];
998 idx->data[j + x_idx_0 * vstride] = iidx->data[x_idx_0];
999 }
1000
1001 j++;
1002 }
1003
1004 emxFree_int32_T(&iidx);
1005 emxFree_real_T(&vwork);
1006 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
1007 }
1008
1009 static void b_sortIdx(const emlrtStack *sp, emxArray_real_T *x, emxArray_int32_T
1010 *idx)
1011 {
1012 emxArray_real_T *b_x;
1013 int32_T ib;
1014 int32_T wOffset;
1015 int32_T m;
1016 int32_T n;
1017 real_T x4[4];
1018 int32_T idx4[4];
1019 emxArray_int32_T *iwork;
1020 emxArray_real_T *xwork;
1021 int32_T nNaNs;
1022 int32_T k;
1023 int8_T perm[4];
1024 int32_T i3;
1025 int32_T i4;
1026 emlrtStack st;
1027 emlrtStack b_st;
1028 emlrtStack c_st;
1029 emlrtStack d_st;
1030 st.prev = sp;
1031 st.tls = sp->tls;
1032 b_st.prev = &st;
1033 b_st.tls = st.tls;
1034 c_st.prev = &b_st;
1035 c_st.tls = b_st.tls;
1036 d_st.prev = &c_st;
1037 d_st.tls = c_st.tls;
1038 emlrtHeapReferenceStackEnterFcnR2012b(sp);
1039 emxInit_real_T(sp, &b_x, 1, &u_emlrtRTEI, true);
1040 ib = x->size[0];
1041 st.site = &hc_emlrtRSI;
1042 b_st.site = &ic_emlrtRSI;
1043 wOffset = b_x->size[0];
1044 b_x->size[0] = x->size[0];
1045 emxEnsureCapacity(&b_st, (emxArray__common *)b_x, wOffset, (int32_T)sizeof
1046 (real_T), &u_emlrtRTEI);
1047 m = x->size[0];
1048 for (wOffset = 0; wOffset < m; wOffset++) {
1049 b_x->data[wOffset] = x->data[wOffset];
1050 }
1051
1052 wOffset = idx->size[0];
1053 idx->size[0] = ib;
1054 emxEnsureCapacity(&b_st, (emxArray__common *)idx, wOffset, (int32_T)sizeof
1055 (int32_T), &u_emlrtRTEI);
1056 for (wOffset = 0; wOffset < ib; wOffset++) {
1057 idx->data[wOffset] = 0;
1058 }
1059
1060 n = x->size[0];
1061 for (m = 0; m < 4; m++) {
1062 x4[m] = 0.0;
1063 idx4[m] = 0;
1064 }
1065
1066 emxInit_int32_T(&b_st, &iwork, 1, &eb_emlrtRTEI, true);
1067 wOffset = iwork->size[0];
1068 iwork->size[0] = ib;
1069 emxEnsureCapacity(&b_st, (emxArray__common *)iwork, wOffset, (int32_T)sizeof
1070 (int32_T), &cb_emlrtRTEI);
1071 m = iwork->size[0];
1072 wOffset = iwork->size[0];
1073 iwork->size[0] = m;
1074 emxEnsureCapacity(&b_st, (emxArray__common *)iwork, wOffset, (int32_T)sizeof
1075 (int32_T), &u_emlrtRTEI);
1076 for (wOffset = 0; wOffset < m; wOffset++) {
1077 iwork->data[wOffset] = 0;
1078 }
1079
1080 emxInit_real_T(&b_st, &xwork, 1, &fb_emlrtRTEI, true);
1081 m = x->size[0];
1082 wOffset = xwork->size[0];
1083 xwork->size[0] = m;
1084 emxEnsureCapacity(&b_st, (emxArray__common *)xwork, wOffset, (int32_T)sizeof
1085 (real_T), &db_emlrtRTEI);
1086 m = xwork->size[0];
1087 wOffset = xwork->size[0];
1088 xwork->size[0] = m;
1089 emxEnsureCapacity(&b_st, (emxArray__common *)xwork, wOffset, (int32_T)sizeof
1090 (real_T), &u_emlrtRTEI);
1091 for (wOffset = 0; wOffset < m; wOffset++) {
1092 xwork->data[wOffset] = 0.0;
1093 }
1094
1095 nNaNs = 0;
1096 ib = 0;
1097 c_st.site = &oc_emlrtRSI;
1098 for (k = 0; k + 1 <= n; k++) {
1099 if (muDoubleScalarIsNaN(b_x->data[k])) {
1100 idx->data[(n - nNaNs) - 1] = k + 1;
1101 xwork->data[(n - nNaNs) - 1] = b_x->data[k];
1102 nNaNs++;
1103 } else {
1104 ib++;
1105 idx4[ib - 1] = k + 1;
1106 x4[ib - 1] = b_x->data[k];
1107 if (ib == 4) {
1108 ib = k - nNaNs;
1109 if (x4[0] <= x4[1]) {
1110 m = 1;
1111 wOffset = 2;
1112 } else {
1113 m = 2;
1114 wOffset = 1;
1115 }
1116
1117 if (x4[2] <= x4[3]) {
1118 i3 = 3;
1119 i4 = 4;
1120 } else {
1121 i3 = 4;
1122 i4 = 3;
1123 }
1124
1125 if (x4[m - 1] <= x4[i3 - 1]) {
1126 if (x4[wOffset - 1] <= x4[i3 - 1]) {
1127 perm[0] = (int8_T)m;
1128 perm[1] = (int8_T)wOffset;
1129 perm[2] = (int8_T)i3;
1130 perm[3] = (int8_T)i4;
1131 } else if (x4[wOffset - 1] <= x4[i4 - 1]) {
1132 perm[0] = (int8_T)m;
1133 perm[1] = (int8_T)i3;
1134 perm[2] = (int8_T)wOffset;
1135 perm[3] = (int8_T)i4;
1136 } else {
1137 perm[0] = (int8_T)m;
1138 perm[1] = (int8_T)i3;
1139 perm[2] = (int8_T)i4;
1140 perm[3] = (int8_T)wOffset;
1141 }
1142 } else if (x4[m - 1] <= x4[i4 - 1]) {
1143 if (x4[wOffset - 1] <= x4[i4 - 1]) {
1144 perm[0] = (int8_T)i3;
1145 perm[1] = (int8_T)m;
1146 perm[2] = (int8_T)wOffset;
1147 perm[3] = (int8_T)i4;
1148 } else {
1149 perm[0] = (int8_T)i3;
1150 perm[1] = (int8_T)m;
1151 perm[2] = (int8_T)i4;
1152 perm[3] = (int8_T)wOffset;
1153 }
1154 } else {
1155 perm[0] = (int8_T)i3;
1156 perm[1] = (int8_T)i4;
1157 perm[2] = (int8_T)m;
1158 perm[3] = (int8_T)wOffset;
1159 }
1160
1161 idx->data[ib - 3] = idx4[perm[0] - 1];
1162 idx->data[ib - 2] = idx4[perm[1] - 1];
1163 idx->data[ib - 1] = idx4[perm[2] - 1];
1164 idx->data[ib] = idx4[perm[3] - 1];
1165 b_x->data[ib - 3] = x4[perm[0] - 1];
1166 b_x->data[ib - 2] = x4[perm[1] - 1];
1167 b_x->data[ib - 1] = x4[perm[2] - 1];
1168 b_x->data[ib] = x4[perm[3] - 1];
1169 ib = 0;
1170 }
1171 }
1172 }
1173
1174 wOffset = (x->size[0] - nNaNs) - 1;
1175 if (ib > 0) {
1176 for (m = 0; m < 4; m++) {
1177 perm[m] = 0;
1178 }
1179
1180 if (ib == 1) {
1181 perm[0] = 1;
1182 } else if (ib == 2) {
1183 if (x4[0] <= x4[1]) {
1184 perm[0] = 1;
1185 perm[1] = 2;
1186 } else {
1187 perm[0] = 2;
1188 perm[1] = 1;
1189 }
1190 } else if (x4[0] <= x4[1]) {
1191 if (x4[1] <= x4[2]) {
1192 perm[0] = 1;
1193 perm[1] = 2;
1194 perm[2] = 3;
1195 } else if (x4[0] <= x4[2]) {
1196 perm[0] = 1;
1197 perm[1] = 3;
1198 perm[2] = 2;
1199 } else {
1200 perm[0] = 3;
1201 perm[1] = 1;
1202 perm[2] = 2;
1203 }
1204 } else if (x4[0] <= x4[2]) {
1205 perm[0] = 2;
1206 perm[1] = 1;
1207 perm[2] = 3;
1208 } else if (x4[1] <= x4[2]) {
1209 perm[0] = 2;
1210 perm[1] = 3;
1211 perm[2] = 1;
1212 } else {
1213 perm[0] = 3;
1214 perm[1] = 2;
1215 perm[2] = 1;
1216 }
1217
1218 c_st.site = &pc_emlrtRSI;
1219 if (ib > 2147483646) {
1220 d_st.site = &w_emlrtRSI;
1221 check_forloop_overflow_error(&d_st);
1222 }
1223
1224 for (k = 1; k <= ib; k++) {
1225 idx->data[(wOffset - ib) + k] = idx4[perm[k - 1] - 1];
1226 b_x->data[(wOffset - ib) + k] = x4[perm[k - 1] - 1];
1227 }
1228 }
1229
1230 m = (nNaNs >> 1) + 1;
1231 c_st.site = &qc_emlrtRSI;
1232 for (k = 1; k < m; k++) {
1233 ib = idx->data[wOffset + k];
1234 idx->data[wOffset + k] = idx->data[n - k];
1235 idx->data[n - k] = ib;
1236 b_x->data[wOffset + k] = xwork->data[n - k];
1237 b_x->data[n - k] = xwork->data[wOffset + k];
1238 }
1239
1240 if ((nNaNs & 1) != 0) {
1241 b_x->data[wOffset + m] = xwork->data[wOffset + m];
1242 }
1243
1244 wOffset = x->size[0] - nNaNs;
1245 m = 2;
1246 if (wOffset > 1) {
1247 if (x->size[0] >= 256) {
1248 ib = wOffset >> 8;
1249 if (ib > 0) {
1250 b_st.site = &jc_emlrtRSI;
1251 for (m = 1; m <= ib; m++) {
1252 b_st.site = &kc_emlrtRSI;
1253 b_merge_pow2_block(idx, b_x, (m - 1) << 8);
1254 }
1255
1256 m = ib << 8;
1257 ib = wOffset - m;
1258 if (ib > 0) {
1259 b_st.site = &lc_emlrtRSI;
1260 b_merge_block(&b_st, idx, b_x, m, ib, 2, iwork, xwork);
1261 }
1262
1263 m = 8;
1264 }
1265 }
1266
1267 b_st.site = &mc_emlrtRSI;
1268 b_merge_block(&b_st, idx, b_x, 0, wOffset, m, iwork, xwork);
1269 }
1270
1271 emxFree_real_T(&xwork);
1272 emxFree_int32_T(&iwork);
1273 wOffset = x->size[0];
1274 x->size[0] = b_x->size[0];
1275 emxEnsureCapacity(sp, (emxArray__common *)x, wOffset, (int32_T)sizeof(real_T),
1276 &u_emlrtRTEI);
1277 m = b_x->size[0];
1278 for (wOffset = 0; wOffset < m; wOffset++) {
1279 x->data[wOffset] = b_x->data[wOffset];
1280 }
1281
1282 emxFree_real_T(&b_x);
1283 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
1284 }
1285
1286 static void c_eml_find(const emlrtStack *sp, const boolean_T x_data[], const
1287 int32_T x_size[1], emxArray_int32_T *i)
1288 {
1289 int32_T nx;
1290 int32_T idx;
1291 int32_T i7;
1292 int32_T ii;
1293 boolean_T exitg1;
1294 boolean_T guard1 = false;
1295 int32_T iv4[2];
1296 emlrtStack st;
1297 st.prev = sp;
1298 st.tls = sp->tls;
1299 nx = x_size[0];
1300 idx = 0;
1301 i7 = i->size[0];
1302 i->size[0] = x_size[0];
1303 emxEnsureCapacity(sp, (emxArray__common *)i, i7, (int32_T)sizeof(int32_T),
1304 &e_emlrtRTEI);
1305 ii = 1;
1306 exitg1 = false;
1307 while ((!exitg1) && (ii <= nx)) {
1308 guard1 = false;
1309 if (x_data[ii - 1]) {
1310 idx++;
1311 i->data[idx - 1] = ii;
1312 if (idx >= nx) {
1313 exitg1 = true;
1314 } else {
1315 guard1 = true;
1316 }
1317 } else {
1318 guard1 = true;
1319 }
1320
1321 if (guard1) {
1322 ii++;
1323 }
1324 }
1325
1326 if (idx <= x_size[0]) {
1327 } else {
1328 emlrtErrorWithMessageIdR2012b(sp, &jb_emlrtRTEI,
1329 "Coder:builtins:AssertionFailed", 0);
1330 }
1331
1332 if (x_size[0] == 1) {
1333 if (idx == 0) {
1334 i7 = i->size[0];
1335 i->size[0] = 0;
1336 emxEnsureCapacity(sp, (emxArray__common *)i, i7, (int32_T)sizeof(int32_T),
1337 &e_emlrtRTEI);
1338 }
1339 } else {
1340 if (1 > idx) {
1341 i7 = 0;
1342 } else {
1343 i7 = idx;
1344 }
1345
1346 iv4[0] = 1;
1347 iv4[1] = i7;
1348 st.site = &o_emlrtRSI;
1349 indexShapeCheck(&st, i->size[0], iv4);
1350 ii = i->size[0];
1351 i->size[0] = i7;
1352 emxEnsureCapacity(sp, (emxArray__common *)i, ii, (int32_T)sizeof(int32_T),
1353 &f_emlrtRTEI);
1354 }
1355 }
1356
1357 static real_T c_emlrt_marshallIn(const emlrtStack *sp, const mxArray
1358 *minpeakhight, const char_T *identifier)
1359 {
1360 real_T y;
1361 emlrtMsgIdentifier thisId;
1362 thisId.fIdentifier = identifier;
1363 thisId.fParent = NULL;
1364 thisId.bParentIsCell = false;
1365 y = d_emlrt_marshallIn(sp, emlrtAlias(minpeakhight), &thisId);
1366 emlrtDestroyArray(&minpeakhight);
1367 return y;
1368 }
1369
1370 static void c_findPeaksSeparatedByMoreThanM(const emlrtStack *sp, const real_T
1371 y[52000], const emxArray_real_T *iPk, int32_T Pd, emxArray_real_T *idx)
1372 {
1373 emxArray_real_T *locs;
1374 emxArray_real_T *locs_temp;
1375 emxArray_boolean_T *idelete;
1376 emxArray_real_T *c_sortIdx;
1377 emxArray_boolean_T *r2;
1378 emxArray_boolean_T *b_idelete;
1379 emxArray_int32_T *iidx;
1380 emxArray_real_T *b_y;
1381 int32_T ndbl;
1382 int32_T i10;
1383 int32_T absb;
1384 int32_T apnd;
1385 int32_T cdiff;
1386 real_T d0;
1387 emlrtStack st;
1388 emlrtStack b_st;
1389 emlrtStack c_st;
1390 st.prev = sp;
1391 st.tls = sp->tls;
1392 b_st.prev = &st;
1393 b_st.tls = st.tls;
1394 c_st.prev = &b_st;
1395 c_st.tls = b_st.tls;
1396 emlrtHeapReferenceStackEnterFcnR2012b(sp);
1397 emxInit_real_T(sp, &locs, 1, &q_emlrtRTEI, true);
1398 emxInit_real_T(sp, &locs_temp, 1, &r_emlrtRTEI, true);
1399 emxInit_boolean_T(sp, &idelete, 1, &s_emlrtRTEI, true);
1400 emxInit_real_T(sp, &c_sortIdx, 1, &p_emlrtRTEI, true);
1401 emxInit_boolean_T(sp, &r2, 1, &p_emlrtRTEI, true);
1402 emxInit_boolean_T(sp, &b_idelete, 1, &p_emlrtRTEI, true);
1403 emxInit_int32_T(sp, &iidx, 1, &p_emlrtRTEI, true);
1404 emxInit_real_T1(sp, &b_y, 2, &p_emlrtRTEI, true);
1405 if ((iPk->size[0] == 0) || (Pd == 0)) {
1406 st.site = &pb_emlrtRSI;
1407 b_st.site = &sb_emlrtRSI;
1408 c_st.site = &tb_emlrtRSI;
1409 if (iPk->size[0] < 1) {
1410 ndbl = 0;
1411 apnd = 0;
1412 } else {
1413 ndbl = (int32_T)muDoubleScalarFloor(((real_T)iPk->size[0] - 1.0) + 0.5);
1414 apnd = ndbl + 1;
1415 cdiff = (ndbl - iPk->size[0]) + 1;
1416 absb = iPk->size[0];
1417 if (muDoubleScalarAbs(cdiff) < 4.4408920985006262E-16 * (real_T)absb) {
1418 ndbl++;
1419 apnd = iPk->size[0];
1420 } else if (cdiff > 0) {
1421 apnd = ndbl;
1422 } else {
1423 ndbl++;
1424 }
1425 }
1426
1427 i10 = b_y->size[0] * b_y->size[1];
1428 b_y->size[0] = 1;
1429 b_y->size[1] = ndbl;
1430 emxEnsureCapacity(&c_st, (emxArray__common *)b_y, i10, (int32_T)sizeof
1431 (real_T), &p_emlrtRTEI);
1432 if (ndbl > 0) {
1433 b_y->data[0] = 1.0;
1434 if (ndbl > 1) {
1435 b_y->data[ndbl - 1] = apnd;
1436 cdiff = (ndbl - 1) / 2;
1437 for (absb = 1; absb < cdiff; absb++) {
1438 b_y->data[absb] = 1.0 + (real_T)absb;
1439 b_y->data[(ndbl - absb) - 1] = apnd - absb;
1440 }
1441
1442 if (cdiff << 1 == ndbl - 1) {
1443 b_y->data[cdiff] = (1.0 + (real_T)apnd) / 2.0;
1444 } else {
1445 b_y->data[cdiff] = 1.0 + (real_T)cdiff;
1446 b_y->data[cdiff + 1] = apnd - cdiff;
1447 }
1448 }
1449 }
1450
1451 i10 = idx->size[0];
1452 idx->size[0] = b_y->size[1];
1453 emxEnsureCapacity(sp, (emxArray__common *)idx, i10, (int32_T)sizeof(real_T),
1454 &p_emlrtRTEI);
1455 ndbl = b_y->size[1];
1456 for (i10 = 0; i10 < ndbl; i10++) {
1457 idx->data[i10] = b_y->data[b_y->size[0] * i10];
1458 }
1459 } else {
1460 ndbl = iPk->size[0];
1461 for (i10 = 0; i10 < ndbl; i10++) {
1462 absb = (int32_T)iPk->data[i10];
1463 if (!((absb >= 1) && (absb <= 52000))) {
1464 emlrtDynamicBoundsCheckR2012b(absb, 1, 52000, &g_emlrtBCI, sp);
1465 }
1466 }
1467
1468 i10 = locs->size[0];
1469 locs->size[0] = iPk->size[0];
1470 emxEnsureCapacity(sp, (emxArray__common *)locs, i10, (int32_T)sizeof(real_T),
1471 &p_emlrtRTEI);
1472 ndbl = iPk->size[0];
1473 for (i10 = 0; i10 < ndbl; i10++) {
1474 locs->data[i10] = 1.0 + (real_T)((int32_T)iPk->data[i10] - 1);
1475 }
1476
1477 st.site = &qb_emlrtRSI;
1478 i10 = locs_temp->size[0];
1479 locs_temp->size[0] = iPk->size[0];
1480 emxEnsureCapacity(&st, (emxArray__common *)locs_temp, i10, (int32_T)sizeof
1481 (real_T), &p_emlrtRTEI);
1482 ndbl = iPk->size[0];
1483 for (i10 = 0; i10 < ndbl; i10++) {
1484 locs_temp->data[i10] = y[(int32_T)iPk->data[i10] - 1];
1485 }
1486
1487 b_st.site = &wb_emlrtRSI;
1488 sort(&b_st, locs_temp, iidx);
1489 i10 = c_sortIdx->size[0];
1490 c_sortIdx->size[0] = iidx->size[0];
1491 emxEnsureCapacity(&st, (emxArray__common *)c_sortIdx, i10, (int32_T)sizeof
1492 (real_T), &p_emlrtRTEI);
1493 ndbl = iidx->size[0];
1494 for (i10 = 0; i10 < ndbl; i10++) {
1495 c_sortIdx->data[i10] = iidx->data[i10];
1496 }
1497
1498 cdiff = iPk->size[0];
1499 i10 = locs_temp->size[0];
1500 locs_temp->size[0] = c_sortIdx->size[0];
1501 emxEnsureCapacity(sp, (emxArray__common *)locs_temp, i10, (int32_T)sizeof
1502 (real_T), &p_emlrtRTEI);
1503 ndbl = c_sortIdx->size[0];
1504 for (i10 = 0; i10 < ndbl; i10++) {
1505 absb = (int32_T)c_sortIdx->data[i10];
1506 if (!((absb >= 1) && (absb <= cdiff))) {
1507 emlrtDynamicBoundsCheckR2012b(absb, 1, cdiff, &h_emlrtBCI, sp);
1508 }
1509
1510 locs_temp->data[i10] = locs->data[absb - 1];
1511 }
1512
1513 cdiff = c_sortIdx->size[0];
1514 i10 = idelete->size[0];
1515 idelete->size[0] = cdiff;
1516 emxEnsureCapacity(sp, (emxArray__common *)idelete, i10, (int32_T)sizeof
1517 (boolean_T), &p_emlrtRTEI);
1518 for (i10 = 0; i10 < cdiff; i10++) {
1519 idelete->data[i10] = false;
1520 }
1521
1522 for (apnd = 1; apnd - 1 < c_sortIdx->size[0]; apnd++) {
1523 i10 = idelete->size[0];
1524 if (!((apnd >= 1) && (apnd <= i10))) {
1525 emlrtDynamicBoundsCheckR2012b(apnd, 1, i10, &j_emlrtBCI, sp);
1526 }
1527
1528 if (!idelete->data[apnd - 1]) {
1529 i10 = c_sortIdx->size[0];
1530 if (!((apnd >= 1) && (apnd <= i10))) {
1531 emlrtDynamicBoundsCheckR2012b(apnd, 1, i10, &k_emlrtBCI, sp);
1532 }
1533
1534 d0 = muDoubleScalarRound(locs->data[(int32_T)c_sortIdx->data[apnd - 1] -
1535 1] - (real_T)Pd);
1536 if (d0 < 2.147483648E+9) {
1537 if (d0 >= -2.147483648E+9) {
1538 cdiff = (int32_T)d0;
1539 } else {
1540 cdiff = MIN_int32_T;
1541 }
1542 } else if (d0 >= 2.147483648E+9) {
1543 cdiff = MAX_int32_T;
1544 } else {
1545 cdiff = 0;
1546 }
1547
1548 i10 = r2->size[0];
1549 r2->size[0] = locs_temp->size[0];
1550 emxEnsureCapacity(sp, (emxArray__common *)r2, i10, (int32_T)sizeof
1551 (boolean_T), &p_emlrtRTEI);
1552 ndbl = locs_temp->size[0];
1553 for (i10 = 0; i10 < ndbl; i10++) {
1554 r2->data[i10] = (locs_temp->data[i10] >= cdiff);
1555 }
1556
1557 i10 = c_sortIdx->size[0];
1558 if (!((apnd >= 1) && (apnd <= i10))) {
1559 emlrtDynamicBoundsCheckR2012b(apnd, 1, i10, &l_emlrtBCI, sp);
1560 }
1561
1562 d0 = muDoubleScalarRound(locs->data[(int32_T)c_sortIdx->data[apnd - 1] -
1563 1] + (real_T)Pd);
1564 if (d0 < 2.147483648E+9) {
1565 if (d0 >= -2.147483648E+9) {
1566 cdiff = (int32_T)d0;
1567 } else {
1568 cdiff = MIN_int32_T;
1569 }
1570 } else if (d0 >= 2.147483648E+9) {
1571 cdiff = MAX_int32_T;
1572 } else {
1573 cdiff = 0;
1574 }
1575
1576 i10 = b_idelete->size[0];
1577 b_idelete->size[0] = locs_temp->size[0];
1578 emxEnsureCapacity(sp, (emxArray__common *)b_idelete, i10, (int32_T)
1579 sizeof(boolean_T), &p_emlrtRTEI);
1580 ndbl = locs_temp->size[0];
1581 for (i10 = 0; i10 < ndbl; i10++) {
1582 b_idelete->data[i10] = (locs_temp->data[i10] <= cdiff);
1583 }
1584
1585 i10 = r2->size[0];
1586 absb = b_idelete->size[0];
1587 if (i10 != absb) {
1588 emlrtSizeEqCheck1DR2012b(i10, absb, &c_emlrtECI, sp);
1589 }
1590
1591 i10 = r2->size[0];
1592 emxEnsureCapacity(sp, (emxArray__common *)r2, i10, (int32_T)sizeof
1593 (boolean_T), &p_emlrtRTEI);
1594 ndbl = r2->size[0];
1595 for (i10 = 0; i10 < ndbl; i10++) {
1596 r2->data[i10] = (r2->data[i10] && b_idelete->data[i10]);
1597 }
1598
1599 i10 = idelete->size[0];
1600 absb = r2->size[0];
1601 if (i10 != absb) {
1602 emlrtSizeEqCheck1DR2012b(i10, absb, &b_emlrtECI, sp);
1603 }
1604
1605 i10 = b_idelete->size[0];
1606 b_idelete->size[0] = idelete->size[0];
1607 emxEnsureCapacity(sp, (emxArray__common *)b_idelete, i10, (int32_T)
1608 sizeof(boolean_T), &p_emlrtRTEI);
1609 ndbl = idelete->size[0];
1610 for (i10 = 0; i10 < ndbl; i10++) {
1611 b_idelete->data[i10] = idelete->data[i10];
1612 }
1613
1614 i10 = idelete->size[0];
1615 emxEnsureCapacity(sp, (emxArray__common *)idelete, i10, (int32_T)sizeof
1616 (boolean_T), &p_emlrtRTEI);
1617 ndbl = idelete->size[0];
1618 for (i10 = 0; i10 < ndbl; i10++) {
1619 idelete->data[i10] = (idelete->data[i10] || r2->data[i10]);
1620 }
1621
1622 i10 = b_idelete->size[0];
1623 if (!((apnd >= 1) && (apnd <= i10))) {
1624 emlrtDynamicBoundsCheckR2012b(apnd, 1, i10, &m_emlrtBCI, sp);
1625 }
1626
1627 idelete->data[apnd - 1] = false;
1628 }
1629 }
1630
1631 absb = idelete->size[0] - 1;
1632 cdiff = 0;
1633 for (apnd = 0; apnd <= absb; apnd++) {
1634 if (!idelete->data[apnd]) {
1635 cdiff++;
1636 }
1637 }
1638
1639 i10 = iidx->size[0];
1640 iidx->size[0] = cdiff;
1641 emxEnsureCapacity(sp, (emxArray__common *)iidx, i10, (int32_T)sizeof(int32_T),
1642 &p_emlrtRTEI);
1643 cdiff = 0;
1644 for (apnd = 0; apnd <= absb; apnd++) {
1645 if (!idelete->data[apnd]) {
1646 iidx->data[cdiff] = apnd + 1;
1647 cdiff++;
1648 }
1649 }
1650
1651 st.site = &rb_emlrtRSI;
1652 cdiff = c_sortIdx->size[0];
1653 ndbl = iidx->size[0];
1654 for (i10 = 0; i10 < ndbl; i10++) {
1655 absb = iidx->data[i10];
1656 if (!((absb >= 1) && (absb <= cdiff))) {
1657 emlrtDynamicBoundsCheckR2012b(absb, 1, cdiff, &i_emlrtBCI, &st);
1658 }
1659 }
1660
1661 i10 = idx->size[0];
1662 idx->size[0] = iidx->size[0];
1663 emxEnsureCapacity(&st, (emxArray__common *)idx, i10, (int32_T)sizeof(real_T),
1664 &p_emlrtRTEI);
1665 ndbl = iidx->size[0];
1666 for (i10 = 0; i10 < ndbl; i10++) {
1667 idx->data[i10] = c_sortIdx->data[iidx->data[i10] - 1];
1668 }
1669
1670 b_st.site = &dd_emlrtRSI;
1671 c_sort(&b_st, idx);
1672 }
1673
1674 emxFree_real_T(&b_y);
1675 emxFree_int32_T(&iidx);
1676 emxFree_boolean_T(&b_idelete);
1677 emxFree_boolean_T(&r2);
1678 emxFree_real_T(&c_sortIdx);
1679 emxFree_boolean_T(&idelete);
1680 emxFree_real_T(&locs_temp);
1681 emxFree_real_T(&locs);
1682 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
1683 }
1684
1685 static void c_sort(const emlrtStack *sp, emxArray_real_T *x)
1686 {
1687 int32_T dim;
1688 int32_T i17;
1689 emxArray_real_T *vwork;
1690 int32_T j;
1691 int32_T vstride;
1692 int32_T k;
1693 emxArray_int32_T *fd_emlrtRSI;
1694 emlrtStack st;
1695 emlrtStack b_st;
1696 emlrtStack c_st;
1697 st.prev = sp;
1698 st.tls = sp->tls;
1699 b_st.prev = &st;
1700 b_st.tls = st.tls;
1701 c_st.prev = &b_st;
1702 c_st.tls = b_st.tls;
1703 emlrtHeapReferenceStackEnterFcnR2012b(sp);
1704 dim = nonSingletonDim(x);
1705 st.site = &yb_emlrtRSI;
1706 assertValidDim();
1707 if (dim <= 1) {
1708 i17 = x->size[0];
1709 } else {
1710 i17 = 1;
1711 }
1712
1713 emxInit_real_T(sp, &vwork, 1, &bb_emlrtRTEI, true);
1714 j = vwork->size[0];
1715 vwork->size[0] = i17;
1716 emxEnsureCapacity(sp, (emxArray__common *)vwork, j, (int32_T)sizeof(real_T),
1717 &t_emlrtRTEI);
1718 st.site = &ac_emlrtRSI;
1719 vstride = 1;
1720 b_st.site = &gc_emlrtRSI;
1721 if ((!(1 > dim - 1)) && (dim - 1 > 2147483646)) {
1722 c_st.site = &w_emlrtRSI;
1723 check_forloop_overflow_error(&c_st);
1724 }
1725
1726 k = 1;
1727 while (k <= dim - 1) {
1728 vstride *= x->size[0];
1729 k = 2;
1730 }
1731
1732 st.site = &bc_emlrtRSI;
1733 st.site = &cc_emlrtRSI;
1734 if ((!(1 > vstride)) && (vstride > 2147483646)) {
1735 b_st.site = &w_emlrtRSI;
1736 check_forloop_overflow_error(&b_st);
1737 }
1738
1739 j = 0;
1740 emxInit_int32_T(sp, &fd_emlrtRSI, 1, &t_emlrtRTEI, true);
1741 while (j + 1 <= vstride) {
1742 st.site = &dc_emlrtRSI;
1743 for (k = 0; k + 1 <= i17; k++) {
1744 vwork->data[k] = x->data[j + k * vstride];
1745 }
1746
1747 st.site = &ec_emlrtRSI;
1748 b_sortIdx(&st, vwork, fd_emlrtRSI);
1749 st.site = &fc_emlrtRSI;
1750 for (k = 0; k + 1 <= i17; k++) {
1751 x->data[j + k * vstride] = vwork->data[k];
1752 }
1753
1754 j++;
1755 }
1756
1757 emxFree_int32_T(&fd_emlrtRSI);
1758 emxFree_real_T(&vwork);
1759 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
1760 }
1761
1762 static void check_forloop_overflow_error(const emlrtStack *sp)
1763 {
1764 emlrtErrorWithMessageIdR2012b(sp, &ib_emlrtRTEI,
1765 "Coder:toolbox:int_forloop_overflow", 3, 4, 5, "int32");
1766 }
1767
1768 static void combinePeaks(const emlrtStack *sp, const emxArray_real_T *iPk, const
1769 emxArray_real_T *iInf, emxArray_real_T *iPkOut)
1770 {
1771 emxArray_int32_T *ia;
1772 emxArray_int32_T *ib;
1773 emlrtStack st;
1774 emlrtStack b_st;
1775 emlrtStack c_st;
1776 st.prev = sp;
1777 st.tls = sp->tls;
1778 b_st.prev = &st;
1779 b_st.tls = st.tls;
1780 c_st.prev = &b_st;
1781 c_st.tls = b_st.tls;
1782 emlrtHeapReferenceStackEnterFcnR2012b(sp);
1783 emxInit_int32_T(sp, &ia, 1, &n_emlrtRTEI, true);
1784 emxInit_int32_T(sp, &ib, 1, &n_emlrtRTEI, true);
1785 st.site = &hb_emlrtRSI;
1786 b_st.site = &ib_emlrtRSI;
1787 c_st.site = &jb_emlrtRSI;
1788 do_vectors(&c_st, iPk, iInf, iPkOut, ia, ib);
1789 emxFree_int32_T(&ib);
1790 emxFree_int32_T(&ia);
1791 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
1792 }
1793
1794 static real_T d_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
1795 emlrtMsgIdentifier *parentId)
1796 {
1797 real_T y;
1798 y = h_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
1799 emlrtDestroyArray(&u);
1800 return y;
1801 }
1802
1803 static void diff(const emlrtStack *sp, const emxArray_real_T *x, emxArray_real_T
1804 *y)
1805 {
1806 int32_T ixLead;
1807 boolean_T b0;
1808 uint16_T ySize_idx_0;
1809 int32_T iyLead;
1810 real_T work_data_idx_0;
1811 int32_T m;
1812 real_T tmp1;
1813 real_T tmp2;
1814 if (x->size[0] == 0) {
1815 ixLead = y->size[0];
1816 y->size[0] = 0;
1817 emxEnsureCapacity(sp, (emxArray__common *)y, ixLead, (int32_T)sizeof(real_T),
1818 &k_emlrtRTEI);
1819 } else {
1820 ixLead = x->size[0] - 1;
1821 if (muIntScalarMin_sint32(ixLead, 1) < 1) {
1822 ixLead = y->size[0];
1823 y->size[0] = 0;
1824 emxEnsureCapacity(sp, (emxArray__common *)y, ixLead, (int32_T)sizeof
1825 (real_T), &k_emlrtRTEI);
1826 } else {
1827 b0 = (x->size[0] != 1);
1828 if (b0) {
1829 } else {
1830 emlrtErrorWithMessageIdR2012b(sp, &hb_emlrtRTEI,
1831 "Coder:toolbox:autoDimIncompatibility", 0);
1832 }
1833
1834 ySize_idx_0 = (uint16_T)(x->size[0] - 1);
1835 ixLead = y->size[0];
1836 y->size[0] = ySize_idx_0;
1837 emxEnsureCapacity(sp, (emxArray__common *)y, ixLead, (int32_T)sizeof
1838 (real_T), &k_emlrtRTEI);
1839 if (!(y->size[0] == 0)) {
1840 ixLead = 1;
1841 iyLead = 0;
1842 work_data_idx_0 = x->data[0];
1843 for (m = 2; m <= x->size[0]; m++) {
1844 tmp1 = x->data[ixLead];
1845 tmp2 = work_data_idx_0;
1846 work_data_idx_0 = tmp1;
1847 tmp1 -= tmp2;
1848 ixLead++;
1849 y->data[iyLead] = tmp1;
1850 iyLead++;
1851 }
1852 }
1853 }
1854 }
1855 }
1856
1857 static boolean_T dimagree(const emxArray_real_T *z, const emxArray_real_T
1858 *varargin_1, const emxArray_real_T *varargin_2)
1859 {
1860 boolean_T p;
1861 boolean_T b_p;
1862 int32_T k;
1863 boolean_T exitg2;
1864 int32_T i8;
1865 boolean_T exitg1;
1866 int32_T i9;
1867 p = true;
1868 b_p = true;
1869 k = 1;
1870 exitg2 = false;
1871 while ((!exitg2) && (k < 3)) {
1872 if (k <= 1) {
1873 i8 = z->size[0];
1874 } else {
1875 i8 = 1;
1876 }
1877
1878 if (k <= 1) {
1879 i9 = varargin_1->size[0];
1880 } else {
1881 i9 = 1;
1882 }
1883
1884 if (i8 != i9) {
1885 b_p = false;
1886 exitg2 = true;
1887 } else {
1888 k++;
1889 }
1890 }
1891
1892 if (b_p) {
1893 b_p = true;
1894 k = 1;
1895 exitg1 = false;
1896 while ((!exitg1) && (k < 3)) {
1897 if (k <= 1) {
1898 i8 = z->size[0];
1899 } else {
1900 i8 = 1;
1901 }
1902
1903 if (k <= 1) {
1904 i9 = varargin_2->size[0];
1905 } else {
1906 i9 = 1;
1907 }
1908
1909 if (i8 != i9) {
1910 b_p = false;
1911 exitg1 = true;
1912 } else {
1913 k++;
1914 }
1915 }
1916
1917 if (b_p) {
1918 } else {
1919 p = false;
1920 }
1921 } else {
1922 p = false;
1923 }
1924
1925 return p;
1926 }
1927
1928 static void do_vectors(const emlrtStack *sp, const emxArray_real_T *a, const
1929 emxArray_real_T *b, emxArray_real_T *c, emxArray_int32_T *ia, emxArray_int32_T
1930 *ib)
1931 {
1932 int32_T na;
1933 int32_T nb;
1934 int32_T ncmax;
1935 int32_T ibfirst;
1936 int32_T nc;
1937 int32_T nia;
1938 int32_T nib;
1939 int32_T iafirst;
1940 int32_T ialast;
1941 int32_T iblast;
1942 int32_T b_ialast;
1943 real_T ak;
1944 int32_T b_iblast;
1945 real_T bk;
1946 real_T absxk;
1947 int32_T exponent;
1948 emxArray_int32_T *b_ia;
1949 emxArray_int32_T *b_ib;
1950 emxArray_real_T *b_c;
1951 emlrtStack st;
1952 st.prev = sp;
1953 st.tls = sp->tls;
1954 emlrtHeapReferenceStackEnterFcnR2012b(sp);
1955 na = a->size[0];
1956 nb = b->size[0];
1957 ncmax = a->size[0] + b->size[0];
1958 ibfirst = c->size[0];
1959 c->size[0] = ncmax;
1960 emxEnsureCapacity(sp, (emxArray__common *)c, ibfirst, (int32_T)sizeof(real_T),
1961 &o_emlrtRTEI);
1962 ibfirst = ia->size[0];
1963 ia->size[0] = a->size[0];
1964 emxEnsureCapacity(sp, (emxArray__common *)ia, ibfirst, (int32_T)sizeof(int32_T),
1965 &o_emlrtRTEI);
1966 ibfirst = ib->size[0];
1967 ib->size[0] = b->size[0];
1968 emxEnsureCapacity(sp, (emxArray__common *)ib, ibfirst, (int32_T)sizeof(int32_T),
1969 &o_emlrtRTEI);
1970 if (!issorted(a)) {
1971 st.site = &lb_emlrtRSI;
1972 error(&st);
1973 }
1974
1975 if (!issorted(b)) {
1976 st.site = &nb_emlrtRSI;
1977 b_error(&st);
1978 }
1979
1980 nc = -1;
1981 nia = 0;
1982 nib = 0;
1983 iafirst = 1;
1984 ialast = 1;
1985 ibfirst = 0;
1986 iblast = 1;
1987 while ((ialast <= na) && (iblast <= nb)) {
1988 b_ialast = ialast;
1989 ak = skip_to_last_equal_value(&b_ialast, a);
1990 ialast = b_ialast;
1991 b_iblast = iblast;
1992 bk = skip_to_last_equal_value(&b_iblast, b);
1993 iblast = b_iblast;
1994 absxk = muDoubleScalarAbs(bk / 2.0);
1995 if (absxk <= 2.2250738585072014E-308) {
1996 absxk = 4.94065645841247E-324;
1997 } else {
1998 frexp(absxk, &exponent);
1999 absxk = ldexp(1.0, exponent - 53);
2000 }
2001
2002 if (muDoubleScalarAbs(bk - ak) < absxk) {
2003 nc++;
2004 c->data[nc] = ak;
2005 nia++;
2006 ia->data[nia - 1] = iafirst;
2007 ialast = b_ialast + 1;
2008 iafirst = b_ialast + 1;
2009 iblast = b_iblast + 1;
2010 ibfirst = b_iblast;
2011 } else if (ak < bk) {
2012 nc++;
2013 nia++;
2014 c->data[nc] = ak;
2015 ia->data[nia - 1] = iafirst;
2016 ialast = b_ialast + 1;
2017 iafirst = b_ialast + 1;
2018 } else {
2019 nc++;
2020 nib++;
2021 c->data[nc] = bk;
2022 ib->data[nib - 1] = ibfirst + 1;
2023 iblast = b_iblast + 1;
2024 ibfirst = b_iblast;
2025 }
2026 }
2027
2028 while (ialast <= na) {
2029 iafirst = ialast;
2030 ak = skip_to_last_equal_value(&iafirst, a);
2031 nc++;
2032 nia++;
2033 c->data[nc] = ak;
2034 ia->data[nia - 1] = ialast;
2035 ialast = iafirst + 1;
2036 }
2037
2038 while (iblast <= nb) {
2039 iafirst = iblast;
2040 bk = skip_to_last_equal_value(&iafirst, b);
2041 nc++;
2042 nib++;
2043 c->data[nc] = bk;
2044 ib->data[nib - 1] = iblast;
2045 iblast = iafirst + 1;
2046 }
2047
2048 if (a->size[0] > 0) {
2049 if (nia <= a->size[0]) {
2050 } else {
2051 emlrtErrorWithMessageIdR2012b(sp, &kb_emlrtRTEI,
2052 "Coder:builtins:AssertionFailed", 0);
2053 }
2054
2055 if (1 > nia) {
2056 iafirst = 0;
2057 } else {
2058 iafirst = nia;
2059 }
2060
2061 emxInit_int32_T(sp, &b_ia, 1, &o_emlrtRTEI, true);
2062 ibfirst = b_ia->size[0];
2063 b_ia->size[0] = iafirst;
2064 emxEnsureCapacity(sp, (emxArray__common *)b_ia, ibfirst, (int32_T)sizeof
2065 (int32_T), &o_emlrtRTEI);
2066 for (ibfirst = 0; ibfirst < iafirst; ibfirst++) {
2067 b_ia->data[ibfirst] = ia->data[ibfirst];
2068 }
2069
2070 ibfirst = ia->size[0];
2071 ia->size[0] = b_ia->size[0];
2072 emxEnsureCapacity(sp, (emxArray__common *)ia, ibfirst, (int32_T)sizeof
2073 (int32_T), &o_emlrtRTEI);
2074 iafirst = b_ia->size[0];
2075 for (ibfirst = 0; ibfirst < iafirst; ibfirst++) {
2076 ia->data[ibfirst] = b_ia->data[ibfirst];
2077 }
2078
2079 emxFree_int32_T(&b_ia);
2080 }
2081
2082 if (b->size[0] > 0) {
2083 if (nib <= b->size[0]) {
2084 } else {
2085 emlrtErrorWithMessageIdR2012b(sp, &lb_emlrtRTEI,
2086 "Coder:builtins:AssertionFailed", 0);
2087 }
2088
2089 if (1 > nib) {
2090 iafirst = 0;
2091 } else {
2092 iafirst = nib;
2093 }
2094
2095 emxInit_int32_T(sp, &b_ib, 1, &o_emlrtRTEI, true);
2096 ibfirst = b_ib->size[0];
2097 b_ib->size[0] = iafirst;
2098 emxEnsureCapacity(sp, (emxArray__common *)b_ib, ibfirst, (int32_T)sizeof
2099 (int32_T), &o_emlrtRTEI);
2100 for (ibfirst = 0; ibfirst < iafirst; ibfirst++) {
2101 b_ib->data[ibfirst] = ib->data[ibfirst];
2102 }
2103
2104 ibfirst = ib->size[0];
2105 ib->size[0] = b_ib->size[0];
2106 emxEnsureCapacity(sp, (emxArray__common *)ib, ibfirst, (int32_T)sizeof
2107 (int32_T), &o_emlrtRTEI);
2108 iafirst = b_ib->size[0];
2109 for (ibfirst = 0; ibfirst < iafirst; ibfirst++) {
2110 ib->data[ibfirst] = b_ib->data[ibfirst];
2111 }
2112
2113 emxFree_int32_T(&b_ib);
2114 }
2115
2116 if (ncmax > 0) {
2117 if (nc + 1 <= ncmax) {
2118 } else {
2119 emlrtErrorWithMessageIdR2012b(sp, &mb_emlrtRTEI,
2120 "Coder:builtins:AssertionFailed", 0);
2121 }
2122
2123 if (1 > nc + 1) {
2124 iafirst = -1;
2125 } else {
2126 iafirst = nc;
2127 }
2128
2129 emxInit_real_T(sp, &b_c, 1, &o_emlrtRTEI, true);
2130 ibfirst = b_c->size[0];
2131 b_c->size[0] = iafirst + 1;
2132 emxEnsureCapacity(sp, (emxArray__common *)b_c, ibfirst, (int32_T)sizeof
2133 (real_T), &o_emlrtRTEI);
2134 for (ibfirst = 0; ibfirst <= iafirst; ibfirst++) {
2135 b_c->data[ibfirst] = c->data[ibfirst];
2136 }
2137
2138 ibfirst = c->size[0];
2139 c->size[0] = b_c->size[0];
2140 emxEnsureCapacity(sp, (emxArray__common *)c, ibfirst, (int32_T)sizeof(real_T),
2141 &o_emlrtRTEI);
2142 iafirst = b_c->size[0];
2143 for (ibfirst = 0; ibfirst < iafirst; ibfirst++) {
2144 c->data[ibfirst] = b_c->data[ibfirst];
2145 }
2146
2147 emxFree_real_T(&b_c);
2148 }
2149
2150 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
2151 }
2152
2153 static int32_T e_emlrt_marshallIn(const emlrtStack *sp, const mxArray
2154 *minpeakdistance, const char_T *identifier)
2155 {
2156 int32_T y;
2157 emlrtMsgIdentifier thisId;
2158 thisId.fIdentifier = identifier;
2159 thisId.fParent = NULL;
2160 thisId.bParentIsCell = false;
2161 y = f_emlrt_marshallIn(sp, emlrtAlias(minpeakdistance), &thisId);
2162 emlrtDestroyArray(&minpeakdistance);
2163 return y;
2164 }
2165
2166 static void eml_find(const emlrtStack *sp, const boolean_T x[52000],
2167 emxArray_int32_T *i)
2168 {
2169 int32_T idx;
2170 int32_T i3;
2171 int32_T ii;
2172 boolean_T exitg1;
2173 boolean_T guard1 = false;
2174 int32_T iv0[2];
2175 emlrtStack st;
2176 st.prev = sp;
2177 st.tls = sp->tls;
2178 idx = 0;
2179 i3 = i->size[0];
2180 i->size[0] = 52000;
2181 emxEnsureCapacity(sp, (emxArray__common *)i, i3, (int32_T)sizeof(int32_T),
2182 &e_emlrtRTEI);
2183 ii = 1;
2184 exitg1 = false;
2185 while ((!exitg1) && (ii < 52001)) {
2186 guard1 = false;
2187 if (x[ii - 1]) {
2188 idx++;
2189 i->data[idx - 1] = ii;
2190 if (idx >= 52000) {
2191 exitg1 = true;
2192 } else {
2193 guard1 = true;
2194 }
2195 } else {
2196 guard1 = true;
2197 }
2198
2199 if (guard1) {
2200 ii++;
2201 }
2202 }
2203
2204 if (1 > idx) {
2205 i3 = 0;
2206 } else {
2207 i3 = idx;
2208 }
2209
2210 iv0[0] = 1;
2211 iv0[1] = i3;
2212 st.site = &o_emlrtRSI;
2213 indexShapeCheck(&st, 52000, iv0);
2214 ii = i->size[0];
2215 i->size[0] = i3;
2216 emxEnsureCapacity(sp, (emxArray__common *)i, ii, (int32_T)sizeof(int32_T),
2217 &f_emlrtRTEI);
2218 }
2219
2220 static real_T (*emlrt_marshallIn(const emlrtStack *sp, const mxArray *Yin, const
2221 char_T *identifier))[52000]
2222 {
2223 real_T (*y)[52000];
2224 emlrtMsgIdentifier thisId;
2225 thisId.fIdentifier = identifier;
2226 thisId.fParent = NULL;
2227 thisId.bParentIsCell = false;
2228 y = b_emlrt_marshallIn(sp, emlrtAlias(Yin), &thisId);
2229 emlrtDestroyArray(&Yin);
2230 return y;
2231 }
2232 static const mxArray *emlrt_marshallOut(const emxArray_real_T *u)
2233 {
2234 const mxArray *y;
2235 const mxArray *m0;
2236 static const int32_T iv5[1] = { 0 };
2237
2238 y = NULL;
2239 m0 = emlrtCreateNumericArray(1, iv5, mxDOUBLE_CLASS, mxREAL);
2240 mxSetData((mxArray *)m0, (void *)u->data);
2241 emlrtSetDimensions((mxArray *)m0, u->size, 1);
2242 emlrtAssign(&y, m0);
2243 return y;
2244 }
2245
2246 static void emxEnsureCapacity(const emlrtStack *sp, emxArray__common *emxArray,
2247 int32_T oldNumel, int32_T elementSize, const emlrtRTEInfo *srcLocation)
2248 {
2249 int32_T newNumel;
2250 int32_T i;
2251 void *newData;
2252 newNumel = 1;
2253 for (i = 0; i < emxArray->numDimensions; i++) {
2254 newNumel = (int32_T)emlrtSizeMulR2012b((uint32_T)newNumel, (uint32_T)
2255 emxArray->size[i], srcLocation, sp);
2256 }
2257
2258 if (newNumel > emxArray->allocatedSize) {
2259 i = emxArray->allocatedSize;
2260 if (i < 16) {
2261 i = 16;
2262 }
2263
2264 while (i < newNumel) {
2265 if (i > 1073741823) {
2266 i = MAX_int32_T;
2267 } else {
2268 i <<= 1;
2269 }
2270 }
2271
2272 newData = emlrtCallocMex((uint32_T)i, (uint32_T)elementSize);
2273 if (newData == NULL) {
2274 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2275 }
2276
2277 if (emxArray->data != NULL) {
2278 memcpy(newData, emxArray->data, (uint32_T)(elementSize * oldNumel));
2279 if (emxArray->canFreeData) {
2280 emlrtFreeMex(emxArray->data);
2281 }
2282 }
2283
2284 emxArray->data = newData;
2285 emxArray->allocatedSize = i;
2286 emxArray->canFreeData = true;
2287 }
2288 }
2289
2290 static void emxFree_boolean_T(emxArray_boolean_T **pEmxArray)
2291 {
2292 if (*pEmxArray != (emxArray_boolean_T *)NULL) {
2293 if (((*pEmxArray)->data != (boolean_T *)NULL) && (*pEmxArray)->canFreeData)
2294 {
2295 emlrtFreeMex((void *)(*pEmxArray)->data);
2296 }
2297
2298 emlrtFreeMex((void *)(*pEmxArray)->size);
2299 emlrtFreeMex((void *)*pEmxArray);
2300 *pEmxArray = (emxArray_boolean_T *)NULL;
2301 }
2302 }
2303
2304 static void emxFree_int32_T(emxArray_int32_T **pEmxArray)
2305 {
2306 if (*pEmxArray != (emxArray_int32_T *)NULL) {
2307 if (((*pEmxArray)->data != (int32_T *)NULL) && (*pEmxArray)->canFreeData) {
2308 emlrtFreeMex((void *)(*pEmxArray)->data);
2309 }
2310
2311 emlrtFreeMex((void *)(*pEmxArray)->size);
2312 emlrtFreeMex((void *)*pEmxArray);
2313 *pEmxArray = (emxArray_int32_T *)NULL;
2314 }
2315 }
2316
2317 static void emxFree_real_T(emxArray_real_T **pEmxArray)
2318 {
2319 if (*pEmxArray != (emxArray_real_T *)NULL) {
2320 if (((*pEmxArray)->data != (real_T *)NULL) && (*pEmxArray)->canFreeData) {
2321 emlrtFreeMex((void *)(*pEmxArray)->data);
2322 }
2323
2324 emlrtFreeMex((void *)(*pEmxArray)->size);
2325 emlrtFreeMex((void *)*pEmxArray);
2326 *pEmxArray = (emxArray_real_T *)NULL;
2327 }
2328 }
2329
2330 static void emxInit_boolean_T(const emlrtStack *sp, emxArray_boolean_T
2331 **pEmxArray, int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T
2332 doPush)
2333 {
2334 emxArray_boolean_T *emxArray;
2335 int32_T i;
2336 *pEmxArray = (emxArray_boolean_T *)emlrtMallocMex(sizeof(emxArray_boolean_T));
2337 if ((void *)*pEmxArray == NULL) {
2338 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2339 }
2340
2341 if (doPush) {
2342 emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
2343 emxFree_boolean_T);
2344 }
2345
2346 emxArray = *pEmxArray;
2347 emxArray->data = (boolean_T *)NULL;
2348 emxArray->numDimensions = numDimensions;
2349 emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
2350 * numDimensions));
2351 if ((void *)emxArray->size == NULL) {
2352 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2353 }
2354
2355 emxArray->allocatedSize = 0;
2356 emxArray->canFreeData = true;
2357 for (i = 0; i < numDimensions; i++) {
2358 emxArray->size[i] = 0;
2359 }
2360 }
2361
2362 static void emxInit_int32_T(const emlrtStack *sp, emxArray_int32_T **pEmxArray,
2363 int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T doPush)
2364 {
2365 emxArray_int32_T *emxArray;
2366 int32_T i;
2367 *pEmxArray = (emxArray_int32_T *)emlrtMallocMex(sizeof(emxArray_int32_T));
2368 if ((void *)*pEmxArray == NULL) {
2369 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2370 }
2371
2372 if (doPush) {
2373 emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
2374 emxFree_int32_T);
2375 }
2376
2377 emxArray = *pEmxArray;
2378 emxArray->data = (int32_T *)NULL;
2379 emxArray->numDimensions = numDimensions;
2380 emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
2381 * numDimensions));
2382 if ((void *)emxArray->size == NULL) {
2383 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2384 }
2385
2386 emxArray->allocatedSize = 0;
2387 emxArray->canFreeData = true;
2388 for (i = 0; i < numDimensions; i++) {
2389 emxArray->size[i] = 0;
2390 }
2391 }
2392
2393 static void emxInit_real_T(const emlrtStack *sp, emxArray_real_T **pEmxArray,
2394 int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T doPush)
2395 {
2396 emxArray_real_T *emxArray;
2397 int32_T i;
2398 *pEmxArray = (emxArray_real_T *)emlrtMallocMex(sizeof(emxArray_real_T));
2399 if ((void *)*pEmxArray == NULL) {
2400 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2401 }
2402
2403 if (doPush) {
2404 emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
2405 emxFree_real_T);
2406 }
2407
2408 emxArray = *pEmxArray;
2409 emxArray->data = (real_T *)NULL;
2410 emxArray->numDimensions = numDimensions;
2411 emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
2412 * numDimensions));
2413 if ((void *)emxArray->size == NULL) {
2414 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2415 }
2416
2417 emxArray->allocatedSize = 0;
2418 emxArray->canFreeData = true;
2419 for (i = 0; i < numDimensions; i++) {
2420 emxArray->size[i] = 0;
2421 }
2422 }
2423
2424 static void emxInit_real_T1(const emlrtStack *sp, emxArray_real_T **pEmxArray,
2425 int32_T numDimensions, const emlrtRTEInfo *srcLocation, boolean_T doPush)
2426 {
2427 emxArray_real_T *emxArray;
2428 int32_T i;
2429 *pEmxArray = (emxArray_real_T *)emlrtMallocMex(sizeof(emxArray_real_T));
2430 if ((void *)*pEmxArray == NULL) {
2431 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2432 }
2433
2434 if (doPush) {
2435 emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
2436 emxFree_real_T);
2437 }
2438
2439 emxArray = *pEmxArray;
2440 emxArray->data = (real_T *)NULL;
2441 emxArray->numDimensions = numDimensions;
2442 emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
2443 * numDimensions));
2444 if ((void *)emxArray->size == NULL) {
2445 emlrtHeapAllocationErrorR2012b(srcLocation, sp);
2446 }
2447
2448 emxArray->allocatedSize = 0;
2449 emxArray->canFreeData = true;
2450 for (i = 0; i < numDimensions; i++) {
2451 emxArray->size[i] = 0;
2452 }
2453 }
2454
2455 static void error(const emlrtStack *sp)
2456 {
2457 emlrtErrorWithMessageIdR2012b(sp, &nb_emlrtRTEI,
2458 "Coder:toolbox:eml_setop_unsortedA", 0);
2459 }
2460
2461 static int32_T f_emlrt_marshallIn(const emlrtStack *sp, const mxArray *u, const
2462 emlrtMsgIdentifier *parentId)
2463 {
2464 int32_T y;
2465 y = i_emlrt_marshallIn(sp, emlrtAlias(u), parentId);
2466 emlrtDestroyArray(&u);
2467 return y;
2468 }
2469
2470 static void findLocalMaxima(matlabfindpeaksStackData *SD, const emlrtStack *sp,
2471 const real_T yTemp[52000], emxArray_real_T *iPk, emxArray_real_T *iInflect)
2472 {
2473 boolean_T yFinite[52002];
2474 int32_T i;
2475 boolean_T b_yTemp[52001];
2476 emxArray_real_T *iNeq;
2477 emxArray_int32_T *ii;
2478 int32_T i4;
2479 int32_T loop_ub;
2480 emxArray_int32_T *r0;
2481 emxArray_real_T *iTemp;
2482 emxArray_real_T *c_yTemp;
2483 emxArray_real_T *s;
2484 emxArray_real_T *r1;
2485 int32_T x_size[1];
2486 boolean_T x_data[52000];
2487 emxArray_int32_T *b_ii;
2488 int32_T iv1[2];
2489 int32_T i5;
2490 int32_T iv2[2];
2491 int32_T s_size[1];
2492 emxArray_int32_T *c_ii;
2493 emlrtStack st;
2494 emlrtStack b_st;
2495 st.prev = sp;
2496 st.tls = sp->tls;
2497 b_st.prev = &st;
2498 b_st.tls = st.tls;
2499 emlrtHeapReferenceStackEnterFcnR2012b(sp);
2500 SD->f0.yTemp[0] = rtNaN;
2501 memcpy(&SD->f0.yTemp[1], &yTemp[0], 52000U * sizeof(real_T));
2502 SD->f0.yTemp[52001] = rtNaN;
2503 for (i = 0; i < 52002; i++) {
2504 yFinite[i] = !muDoubleScalarIsNaN(SD->f0.yTemp[i]);
2505 }
2506
2507 st.site = &q_emlrtRSI;
2508 for (i = 0; i < 52001; i++) {
2509 b_yTemp[i] = ((SD->f0.yTemp[i] != SD->f0.yTemp[i + 1]) && (yFinite[i] ||
2510 yFinite[i + 1]));
2511 }
2512
2513 emxInit_real_T(&st, &iNeq, 1, &h_emlrtRTEI, true);
2514 emxInit_int32_T(&st, &ii, 1, &d_emlrtRTEI, true);
2515 b_st.site = &n_emlrtRSI;
2516 b_eml_find(&b_st, b_yTemp, ii);
2517 i4 = iNeq->size[0];
2518 iNeq->size[0] = 1 + ii->size[0];
2519 emxEnsureCapacity(sp, (emxArray__common *)iNeq, i4, (int32_T)sizeof(real_T),
2520 &g_emlrtRTEI);
2521 iNeq->data[0] = 1.0;
2522 loop_ub = ii->size[0];
2523 for (i4 = 0; i4 < loop_ub; i4++) {
2524 iNeq->data[i4 + 1] = 1.0 + (real_T)ii->data[i4];
2525 }
2526
2527 emxInit_int32_T(sp, &r0, 1, &g_emlrtRTEI, true);
2528 i4 = r0->size[0];
2529 r0->size[0] = 1 + ii->size[0];
2530 emxEnsureCapacity(sp, (emxArray__common *)r0, i4, (int32_T)sizeof(int32_T),
2531 &g_emlrtRTEI);
2532 r0->data[0] = 1;
2533 loop_ub = ii->size[0];
2534 for (i4 = 0; i4 < loop_ub; i4++) {
2535 r0->data[i4 + 1] = ii->data[i4] + 1;
2536 }
2537
2538 emxFree_int32_T(&ii);
2539 emxInit_real_T(sp, &iTemp, 1, &j_emlrtRTEI, true);
2540 i4 = iTemp->size[0];
2541 iTemp->size[0] = r0->size[0];
2542 emxEnsureCapacity(sp, (emxArray__common *)iTemp, i4, (int32_T)sizeof(real_T),
2543 &g_emlrtRTEI);
2544 loop_ub = r0->size[0];
2545 for (i4 = 0; i4 < loop_ub; i4++) {
2546 iTemp->data[i4] = 1.0 + (real_T)(r0->data[i4] - 1);
2547 }
2548
2549 emxFree_int32_T(&r0);
2550 emxInit_real_T(sp, &c_yTemp, 1, &g_emlrtRTEI, true);
2551 i4 = c_yTemp->size[0];
2552 c_yTemp->size[0] = iTemp->size[0];
2553 emxEnsureCapacity(sp, (emxArray__common *)c_yTemp, i4, (int32_T)sizeof(real_T),
2554 &g_emlrtRTEI);
2555 loop_ub = iTemp->size[0];
2556 for (i4 = 0; i4 < loop_ub; i4++) {
2557 c_yTemp->data[i4] = SD->f0.yTemp[(int32_T)iTemp->data[i4] - 1];
2558 }
2559
2560 emxInit_real_T(sp, &s, 1, &i_emlrtRTEI, true);
2561 emxInit_real_T(sp, &r1, 1, &g_emlrtRTEI, true);
2562 st.site = &r_emlrtRSI;
2563 diff(&st, c_yTemp, s);
2564 st.site = &r_emlrtRSI;
2565 b_sign(s);
2566 st.site = &s_emlrtRSI;
2567 b_st.site = &s_emlrtRSI;
2568 diff(&b_st, s, r1);
2569 x_size[0] = r1->size[0];
2570 loop_ub = r1->size[0];
2571 emxFree_real_T(&c_yTemp);
2572 for (i4 = 0; i4 < loop_ub; i4++) {
2573 x_data[i4] = (r1->data[i4] < 0.0);
2574 }
2575
2576 emxFree_real_T(&r1);
2577 emxInit_int32_T(&st, &b_ii, 1, &d_emlrtRTEI, true);
2578 b_st.site = &n_emlrtRSI;
2579 c_eml_find(&b_st, x_data, x_size, b_ii);
2580 if (1 > s->size[0] - 1) {
2581 loop_ub = 0;
2582 } else {
2583 i4 = s->size[0];
2584 if (!(1 <= i4)) {
2585 emlrtDynamicBoundsCheckR2012b(1, 1, i4, &c_emlrtBCI, sp);
2586 }
2587
2588 i4 = s->size[0];
2589 loop_ub = s->size[0] - 1;
2590 if (!((loop_ub >= 1) && (loop_ub <= i4))) {
2591 emlrtDynamicBoundsCheckR2012b(loop_ub, 1, i4, &c_emlrtBCI, sp);
2592 }
2593 }
2594
2595 iv1[0] = 1;
2596 iv1[1] = loop_ub;
2597 st.site = &t_emlrtRSI;
2598 indexShapeCheck(&st, s->size[0], iv1);
2599 if (2 > s->size[0]) {
2600 i4 = 1;
2601 i5 = 1;
2602 } else {
2603 i4 = 2;
2604 i5 = s->size[0];
2605 i = s->size[0];
2606 if (!((i >= 1) && (i <= i5))) {
2607 emlrtDynamicBoundsCheckR2012b(i, 1, i5, &d_emlrtBCI, sp);
2608 }
2609
2610 i5 = i + 1;
2611 }
2612
2613 iv2[0] = 1;
2614 iv2[1] = i5 - i4;
2615 st.site = &t_emlrtRSI;
2616 indexShapeCheck(&st, s->size[0], iv2);
2617 i5 -= i4;
2618 if (loop_ub != i5) {
2619 emlrtSizeEqCheck1DR2012b(loop_ub, i5, &emlrtECI, sp);
2620 }
2621
2622 st.site = &t_emlrtRSI;
2623 s_size[0] = loop_ub;
2624 for (i5 = 0; i5 < loop_ub; i5++) {
2625 x_data[i5] = (s->data[i5] != s->data[(i4 + i5) - 1]);
2626 }
2627
2628 emxFree_real_T(&s);
2629 emxInit_int32_T(&st, &c_ii, 1, &d_emlrtRTEI, true);
2630 b_st.site = &n_emlrtRSI;
2631 c_eml_find(&b_st, x_data, s_size, c_ii);
2632 i = iNeq->size[0];
2633 i4 = iInflect->size[0];
2634 iInflect->size[0] = c_ii->size[0];
2635 emxEnsureCapacity(sp, (emxArray__common *)iInflect, i4, (int32_T)sizeof(real_T),
2636 &g_emlrtRTEI);
2637 loop_ub = c_ii->size[0];
2638 for (i4 = 0; i4 < loop_ub; i4++) {
2639 i5 = c_ii->data[i4] + 1;
2640 if (!((i5 >= 1) && (i5 <= i))) {
2641 emlrtDynamicBoundsCheckR2012b(i5, 1, i, &e_emlrtBCI, sp);
2642 }
2643
2644 iInflect->data[i4] = iTemp->data[i5 - 1] - 1.0;
2645 }
2646
2647 emxFree_int32_T(&c_ii);
2648 i = iNeq->size[0];
2649 i4 = iPk->size[0];
2650 iPk->size[0] = b_ii->size[0];
2651 emxEnsureCapacity(sp, (emxArray__common *)iPk, i4, (int32_T)sizeof(real_T),
2652 &g_emlrtRTEI);
2653 loop_ub = b_ii->size[0];
2654 emxFree_real_T(&iNeq);
2655 for (i4 = 0; i4 < loop_ub; i4++) {
2656 i5 = b_ii->data[i4] + 1;
2657 if (!((i5 >= 1) && (i5 <= i))) {
2658 emlrtDynamicBoundsCheckR2012b(i5, 1, i, &f_emlrtBCI, sp);
2659 }
2660
2661 iPk->data[i4] = iTemp->data[i5 - 1] - 1.0;
2662 }
2663
2664 emxFree_int32_T(&b_ii);
2665 emxFree_real_T(&iTemp);
2666 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
2667 }
2668
2669 static void findpeaks(matlabfindpeaksStackData *SD, const emlrtStack *sp, const
2670 real_T Yin[52000], real_T varargin_2, int32_T varargin_4,
2671 emxArray_real_T *Ypk, emxArray_real_T *Xpk)
2672 {
2673 emxArray_real_T *iPk;
2674 emxArray_real_T *iFinite;
2675 emxArray_real_T *iInfite;
2676 emxArray_real_T *iInflect;
2677 real_T minH;
2678 int32_T minD;
2679 int32_T i0;
2680 int32_T loop_ub;
2681 emxArray_real_T *b_iPk;
2682 emxArray_real_T *c_iPk;
2683 int32_T i1;
2684 emlrtStack st;
2685 st.prev = sp;
2686 st.tls = sp->tls;
2687 emlrtHeapReferenceStackEnterFcnR2012b(sp);
2688 memcpy(&SD->f2.y[0], &Yin[0], 52000U * sizeof(real_T));
2689 emxInit_real_T(sp, &iPk, 1, &b_emlrtRTEI, true);
2690 emxInit_real_T(sp, &iFinite, 1, &emlrtRTEI, true);
2691 emxInit_real_T(sp, &iInfite, 1, &emlrtRTEI, true);
2692 emxInit_real_T(sp, &iInflect, 1, &emlrtRTEI, true);
2693 st.site = &b_emlrtRSI;
2694 parse_inputs(&st, varargin_2, varargin_4, &minH, &minD);
2695 st.site = &c_emlrtRSI;
2696 getAllPeaks(SD, &st, SD->f2.y, iFinite, iInfite, iInflect);
2697 st.site = &d_emlrtRSI;
2698 removePeaksBelowMinPeakHeight(&st, SD->f2.y, iFinite, minH);
2699 i0 = iPk->size[0];
2700 iPk->size[0] = iFinite->size[0];
2701 emxEnsureCapacity(sp, (emxArray__common *)iPk, i0, (int32_T)sizeof(real_T),
2702 &emlrtRTEI);
2703 loop_ub = iFinite->size[0];
2704 emxFree_real_T(&iInflect);
2705 for (i0 = 0; i0 < loop_ub; i0++) {
2706 iPk->data[i0] = iFinite->data[i0];
2707 }
2708
2709 i0 = iFinite->size[0];
2710 iFinite->size[0] = iPk->size[0];
2711 emxEnsureCapacity(sp, (emxArray__common *)iFinite, i0, (int32_T)sizeof(real_T),
2712 &emlrtRTEI);
2713 loop_ub = iPk->size[0];
2714 for (i0 = 0; i0 < loop_ub; i0++) {
2715 iFinite->data[i0] = iPk->data[i0];
2716 }
2717
2718 st.site = &e_emlrtRSI;
2719 removePeaksBelowThreshold(&st, SD->f2.y, iFinite);
2720 i0 = iPk->size[0];
2721 iPk->size[0] = iFinite->size[0];
2722 emxEnsureCapacity(sp, (emxArray__common *)iPk, i0, (int32_T)sizeof(real_T),
2723 &emlrtRTEI);
2724 loop_ub = iFinite->size[0];
2725 for (i0 = 0; i0 < loop_ub; i0++) {
2726 iPk->data[i0] = iFinite->data[i0];
2727 }
2728
2729 emxFree_real_T(&iFinite);
2730 emxInit_real_T(sp, &b_iPk, 1, &emlrtRTEI, true);
2731 st.site = &f_emlrtRSI;
2732 combinePeaks(&st, iPk, iInfite, b_iPk);
2733 st.site = &g_emlrtRSI;
2734 c_findPeaksSeparatedByMoreThanM(&st, SD->f2.y, b_iPk, minD, iPk);
2735 st.site = &h_emlrtRSI;
2736 keepAtMostNpPeaks(&st, iPk);
2737 minD = b_iPk->size[0];
2738 loop_ub = iPk->size[0];
2739 emxFree_real_T(&iInfite);
2740 for (i0 = 0; i0 < loop_ub; i0++) {
2741 minH = iPk->data[i0];
2742 if (minH != (int32_T)muDoubleScalarFloor(minH)) {
2743 emlrtIntegerCheckR2012b(minH, &emlrtDCI, sp);
2744 }
2745
2746 i1 = (int32_T)minH;
2747 if (!((i1 >= 1) && (i1 <= minD))) {
2748 emlrtDynamicBoundsCheckR2012b(i1, 1, minD, &emlrtBCI, sp);
2749 }
2750 }
2751
2752 for (i0 = 0; i0 < 52000; i0++) {
2753 SD->f2.dv0[i0] = 1.0 + (real_T)i0;
2754 }
2755
2756 emxInit_real_T(sp, &c_iPk, 1, &emlrtRTEI, true);
2757 i0 = c_iPk->size[0];
2758 c_iPk->size[0] = iPk->size[0];
2759 emxEnsureCapacity(sp, (emxArray__common *)c_iPk, i0, (int32_T)sizeof(real_T),
2760 &emlrtRTEI);
2761 loop_ub = iPk->size[0];
2762 for (i0 = 0; i0 < loop_ub; i0++) {
2763 c_iPk->data[i0] = b_iPk->data[(int32_T)iPk->data[i0] - 1];
2764 }
2765
2766 emxFree_real_T(&b_iPk);
2767 emxFree_real_T(&iPk);
2768 st.site = &i_emlrtRSI;
2769 assignOutputs(&st, SD->f2.y, SD->f2.dv0, c_iPk, Ypk, Xpk);
2770 emxFree_real_T(&c_iPk);
2771 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
2772 }
2773
2774 static real_T (*g_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
2775 const emlrtMsgIdentifier *msgId))[52000]
2776 {
2777 real_T (*ret)[52000];
2778 static const int32_T dims[1] = { 52000 };
2779
2780 emlrtCheckBuiltInR2012b(sp, msgId, src, "double", false, 1U, dims);
2781 ret = (real_T (*)[52000])mxGetData(src);
2782 emlrtDestroyArray(&src);
2783 return ret;
2784 }
2785 static void getAllPeaks(matlabfindpeaksStackData *SD, const emlrtStack *sp,
2786 const real_T y[52000], emxArray_real_T *iPk, emxArray_real_T *iInf,
2787 emxArray_real_T *iInflect)
2788 {
2789 int32_T i;
2790 emxArray_int32_T *ii;
2791 int32_T loop_ub;
2792 int32_T i2;
2793 emlrtStack st;
2794 emlrtStack b_st;
2795 st.prev = sp;
2796 st.tls = sp->tls;
2797 b_st.prev = &st;
2798 b_st.tls = st.tls;
2799 emlrtHeapReferenceStackEnterFcnR2012b(sp);
2800 st.site = &l_emlrtRSI;
2801 for (i = 0; i < 52000; i++) {
2802 SD->f1.bv0[i] = (muDoubleScalarIsInf(y[i]) && (y[i] > 0.0));
2803 }
2804
2805 emxInit_int32_T(&st, &ii, 1, &d_emlrtRTEI, true);
2806 b_st.site = &n_emlrtRSI;
2807 eml_find(&b_st, SD->f1.bv0, ii);
2808 i = iInf->size[0];
2809 iInf->size[0] = ii->size[0];
2810 emxEnsureCapacity(&st, (emxArray__common *)iInf, i, (int32_T)sizeof(real_T),
2811 &c_emlrtRTEI);
2812 loop_ub = ii->size[0];
2813 for (i = 0; i < loop_ub; i++) {
2814 iInf->data[i] = ii->data[i];
2815 }
2816
2817 memcpy(&SD->f1.yTemp[0], &y[0], 52000U * sizeof(real_T));
2818 i = ii->size[0];
2819 ii->size[0] = iInf->size[0];
2820 emxEnsureCapacity(sp, (emxArray__common *)ii, i, (int32_T)sizeof(int32_T),
2821 &c_emlrtRTEI);
2822 loop_ub = iInf->size[0];
2823 for (i = 0; i < loop_ub; i++) {
2824 i2 = (int32_T)iInf->data[i];
2825 if (!((i2 >= 1) && (i2 <= 52000))) {
2826 emlrtDynamicBoundsCheckR2012b(i2, 1, 52000, &b_emlrtBCI, sp);
2827 }
2828
2829 ii->data[i] = i2;
2830 }
2831
2832 loop_ub = ii->size[0];
2833 for (i = 0; i < loop_ub; i++) {
2834 SD->f1.yTemp[ii->data[i] - 1] = rtNaN;
2835 }
2836
2837 emxFree_int32_T(&ii);
2838 st.site = &m_emlrtRSI;
2839 findLocalMaxima(SD, &st, SD->f1.yTemp, iPk, iInflect);
2840 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
2841 }
2842
2843 static real_T h_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src, const
2844 emlrtMsgIdentifier *msgId)
2845 {
2846 real_T ret;
2847 static const int32_T dims = 0;
2848 emlrtCheckBuiltInR2012b(sp, msgId, src, "double", false, 0U, &dims);
2849 ret = *(real_T *)mxGetData(src);
2850 emlrtDestroyArray(&src);
2851 return ret;
2852 }
2853
2854 static int32_T i_emlrt_marshallIn(const emlrtStack *sp, const mxArray *src,
2855 const emlrtMsgIdentifier *msgId)
2856 {
2857 int32_T ret;
2858 static const int32_T dims = 0;
2859 emlrtCheckBuiltInR2012b(sp, msgId, src, "int32", false, 0U, &dims);
2860 ret = *(int32_T *)mxGetData(src);
2861 emlrtDestroyArray(&src);
2862 return ret;
2863 }
2864
2865 static void indexShapeCheck(const emlrtStack *sp, int32_T matrixSize, const
2866 int32_T indexSize[2])
2867 {
2868 boolean_T guard1 = false;
2869 boolean_T nonSingletonDimFound;
2870 emlrtStack st;
2871 st.prev = sp;
2872 st.tls = sp->tls;
2873 guard1 = false;
2874 if (!(matrixSize != 1)) {
2875 nonSingletonDimFound = false;
2876 if (indexSize[1] != 1) {
2877 nonSingletonDimFound = true;
2878 }
2879
2880 if (nonSingletonDimFound) {
2881 nonSingletonDimFound = true;
2882 } else {
2883 guard1 = true;
2884 }
2885 } else {
2886 guard1 = true;
2887 }
2888
2889 if (guard1) {
2890 nonSingletonDimFound = false;
2891 }
2892
2893 st.site = &p_emlrtRSI;
2894 if (!nonSingletonDimFound) {
2895 } else {
2896 emlrtErrorWithMessageIdR2012b(&st, &gb_emlrtRTEI,
2897 "Coder:FE:PotentialVectorVector", 0);
2898 }
2899 }
2900
2901 static boolean_T issorted(const emxArray_real_T *x)
2902 {
2903 boolean_T y;
2904 int32_T k;
2905 boolean_T exitg1;
2906 boolean_T p;
2907 y = true;
2908 if (x->size[0] == 0) {
2909 } else {
2910 k = 1;
2911 exitg1 = false;
2912 while ((!exitg1) && (k <= x->size[0] - 1)) {
2913 p = (x->data[k - 1] <= x->data[k]);
2914 if (!p) {
2915 y = false;
2916 exitg1 = true;
2917 } else {
2918 k++;
2919 }
2920 }
2921 }
2922
2923 return y;
2924 }
2925
2926 static void keepAtMostNpPeaks(const emlrtStack *sp, emxArray_real_T *idx)
2927 {
2928 boolean_T b;
2929 emxArray_real_T *b_idx;
2930 int32_T c_idx;
2931 int32_T i18;
2932 int32_T i19;
2933 emlrtStack st;
2934 emlrtStack b_st;
2935 st.prev = sp;
2936 st.tls = sp->tls;
2937 b_st.prev = &st;
2938 b_st.tls = st.tls;
2939 emlrtHeapReferenceStackEnterFcnR2012b(sp);
2940 if (idx->size[0] > 52000) {
2941 st.site = &ed_emlrtRSI;
2942 b = !(idx->size[0] != 1);
2943 b_st.site = &p_emlrtRSI;
2944 if (!b) {
2945 } else {
2946 emlrtErrorWithMessageIdR2012b(&b_st, &gb_emlrtRTEI,
2947 "Coder:FE:PotentialVectorVector", 0);
2948 }
2949
2950 emxInit_real_T(&b_st, &b_idx, 1, &v_emlrtRTEI, true);
2951 c_idx = idx->size[0];
2952 i18 = b_idx->size[0];
2953 b_idx->size[0] = 52000;
2954 emxEnsureCapacity(sp, (emxArray__common *)b_idx, i18, (int32_T)sizeof(real_T),
2955 &v_emlrtRTEI);
2956 for (i18 = 0; i18 < 52000; i18++) {
2957 i19 = 1 + i18;
2958 if (!(i19 <= c_idx)) {
2959 emlrtDynamicBoundsCheckR2012b(i19, 1, c_idx, &u_emlrtBCI, sp);
2960 }
2961
2962 b_idx->data[i18] = idx->data[i19 - 1];
2963 }
2964
2965 i18 = idx->size[0];
2966 idx->size[0] = b_idx->size[0];
2967 emxEnsureCapacity(sp, (emxArray__common *)idx, i18, (int32_T)sizeof(real_T),
2968 &v_emlrtRTEI);
2969 c_idx = b_idx->size[0];
2970 for (i18 = 0; i18 < c_idx; i18++) {
2971 idx->data[i18] = b_idx->data[i18];
2972 }
2973
2974 emxFree_real_T(&b_idx);
2975 }
2976
2977 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
2978 }
2979
2980 static void matlabfindpeaks_once(void)
2981 {
2982 /* Allocate instance data */
2983 covrtAllocateInstanceData(&emlrtCoverageInstance);
2984
2985 /* Initialize Coverage Information */
2986 covrtScriptInit(&emlrtCoverageInstance,
2987 "C:\\\\Users\\\\86188\\\\Desktop\\\\\xd1\xb0\xb7\xe5\xcb\xe3\xb7\xa8\\\\matlabfindpeaks.m",
2988 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0);
2989
2990 /* Initialize Function Information */
2991 covrtFcnInit(&emlrtCoverageInstance, 0, 0, "matlabfindpeaks", 17, -1, 196);
2992
2993 /* Initialize Basic Block Information */
2994 covrtBasicBlockInit(&emlrtCoverageInstance, 0, 0, 93, -1, 183);
2995
2996 /* Initialize If Information */
2997 /* Initialize MCDC Information */
2998 /* Initialize For Information */
2999 /* Initialize While Information */
3000 /* Initialize Switch Information */
3001 /* Start callback for coverage engine */
3002 covrtScriptStart(&emlrtCoverageInstance, 0U);
3003 }
3004
3005 static void merge(const emlrtStack *sp, emxArray_int32_T *idx, emxArray_real_T
3006 *x, int32_T offset, int32_T np, int32_T nq, emxArray_int32_T
3007 *iwork, emxArray_real_T *xwork)
3008 {
3009 int32_T n;
3010 int32_T qend;
3011 int32_T p;
3012 int32_T iout;
3013 int32_T exitg1;
3014 emlrtStack st;
3015 emlrtStack b_st;
3016 st.prev = sp;
3017 st.tls = sp->tls;
3018 b_st.prev = &st;
3019 b_st.tls = st.tls;
3020 if (nq == 0) {
3021 } else {
3022 n = np + nq;
3023 st.site = &ad_emlrtRSI;
3024 if ((!(1 > n)) && (n > 2147483646)) {
3025 b_st.site = &w_emlrtRSI;
3026 check_forloop_overflow_error(&b_st);
3027 }
3028
3029 for (qend = 0; qend + 1 <= n; qend++) {
3030 iwork->data[qend] = idx->data[offset + qend];
3031 xwork->data[qend] = x->data[offset + qend];
3032 }
3033
3034 p = 0;
3035 n = np;
3036 qend = np + nq;
3037 iout = offset - 1;
3038 do {
3039 exitg1 = 0;
3040 iout++;
3041 if (xwork->data[p] >= xwork->data[n]) {
3042 idx->data[iout] = iwork->data[p];
3043 x->data[iout] = xwork->data[p];
3044 if (p + 1 < np) {
3045 p++;
3046 } else {
3047 exitg1 = 1;
3048 }
3049 } else {
3050 idx->data[iout] = iwork->data[n];
3051 x->data[iout] = xwork->data[n];
3052 if (n + 1 < qend) {
3053 n++;
3054 } else {
3055 n = (iout - p) + 1;
3056 st.site = &yc_emlrtRSI;
3057 if ((!(p + 1 > np)) && (np > 2147483646)) {
3058 b_st.site = &w_emlrtRSI;
3059 check_forloop_overflow_error(&b_st);
3060 }
3061
3062 while (p + 1 <= np) {
3063 idx->data[n + p] = iwork->data[p];
3064 x->data[n + p] = xwork->data[p];
3065 p++;
3066 }
3067
3068 exitg1 = 1;
3069 }
3070 }
3071 } while (exitg1 == 0);
3072 }
3073 }
3074
3075 static void merge_block(const emlrtStack *sp, emxArray_int32_T *idx,
3076 emxArray_real_T *x, int32_T offset, int32_T n, int32_T preSortLevel,
3077 emxArray_int32_T *iwork, emxArray_real_T *xwork)
3078 {
3079 int32_T nPairs;
3080 int32_T bLen;
3081 int32_T tailOffset;
3082 int32_T nTail;
3083 emlrtStack st;
3084 st.prev = sp;
3085 st.tls = sp->tls;
3086 nPairs = n >> preSortLevel;
3087 bLen = 1 << preSortLevel;
3088 while (nPairs > 1) {
3089 if ((nPairs & 1) != 0) {
3090 nPairs--;
3091 tailOffset = bLen * nPairs;
3092 nTail = n - tailOffset;
3093 if (nTail > bLen) {
3094 st.site = &uc_emlrtRSI;
3095 merge(&st, idx, x, offset + tailOffset, bLen, nTail - bLen, iwork, xwork);
3096 }
3097 }
3098
3099 tailOffset = bLen << 1;
3100 nPairs >>= 1;
3101 for (nTail = 1; nTail <= nPairs; nTail++) {
3102 st.site = &wc_emlrtRSI;
3103 merge(&st, idx, x, offset + (nTail - 1) * tailOffset, bLen, bLen, iwork,
3104 xwork);
3105 }
3106
3107 bLen = tailOffset;
3108 }
3109
3110 if (n > bLen) {
3111 st.site = &xc_emlrtRSI;
3112 merge(&st, idx, x, offset, bLen, n - bLen, iwork, xwork);
3113 }
3114 }
3115
3116 static void merge_pow2_block(emxArray_int32_T *idx, emxArray_real_T *x, int32_T
3117 offset)
3118 {
3119 int32_T iwork[256];
3120 real_T xwork[256];
3121 int32_T b;
3122 int32_T bLen;
3123 int32_T bLen2;
3124 int32_T nPairs;
3125 int32_T k;
3126 int32_T blockOffset;
3127 int32_T iout;
3128 int32_T p;
3129 int32_T q;
3130 int32_T exitg1;
3131 for (b = 0; b < 6; b++) {
3132 bLen = 1 << (b + 2);
3133 bLen2 = bLen << 1;
3134 nPairs = 256 >> (b + 3);
3135 for (k = 1; k <= nPairs; k++) {
3136 blockOffset = offset + (k - 1) * bLen2;
3137 for (iout = 0; iout + 1 <= bLen2; iout++) {
3138 iwork[iout] = idx->data[blockOffset + iout];
3139 xwork[iout] = x->data[blockOffset + iout];
3140 }
3141
3142 p = 0;
3143 q = bLen;
3144 iout = blockOffset - 1;
3145 do {
3146 exitg1 = 0;
3147 iout++;
3148 if (xwork[p] >= xwork[q]) {
3149 idx->data[iout] = iwork[p];
3150 x->data[iout] = xwork[p];
3151 if (p + 1 < bLen) {
3152 p++;
3153 } else {
3154 exitg1 = 1;
3155 }
3156 } else {
3157 idx->data[iout] = iwork[q];
3158 x->data[iout] = xwork[q];
3159 if (q + 1 < bLen2) {
3160 q++;
3161 } else {
3162 iout = (iout - p) + 1;
3163 while (p + 1 <= bLen) {
3164 idx->data[iout + p] = iwork[p];
3165 x->data[iout + p] = xwork[p];
3166 p++;
3167 }
3168
3169 exitg1 = 1;
3170 }
3171 }
3172 } while (exitg1 == 0);
3173 }
3174 }
3175 }
3176
3177 static int32_T nonSingletonDim(const emxArray_real_T *x)
3178 {
3179 int32_T dim;
3180 dim = 2;
3181 if (x->size[0] != 1) {
3182 dim = 1;
3183 }
3184
3185 return dim;
3186 }
3187
3188 static void parse_inputs(const emlrtStack *sp, real_T varargin_2, int32_T
3189 varargin_4, real_T *Ph, int32_T *Pd)
3190 {
3191 boolean_T p;
3192 emlrtStack st;
3193 st.prev = sp;
3194 st.tls = sp->tls;
3195 *Ph = varargin_2;
3196 *Pd = varargin_4;
3197 st.site = &j_emlrtRSI;
3198 p = true;
3199 if (!(varargin_4 < 0)) {
3200 } else {
3201 p = false;
3202 }
3203
3204 if (p) {
3205 } else {
3206 emlrtErrMsgIdAndExplicitTxt(&st, &ob_emlrtRTEI,
3207 "MATLAB:findpeaks:expectedNonnegative", 43,
3208 "Expected MinPeakDistance to be nonnegative.");
3209 }
3210
3211 p = true;
3212 if (varargin_4 < 51999) {
3213 } else {
3214 p = false;
3215 }
3216
3217 if (p) {
3218 } else {
3219 emlrtErrMsgIdAndExplicitTxt(&st, &pb_emlrtRTEI, "MATLAB:findpeaks:notLess",
3220 71,
3221 "Expected MinPeakDistance to be an array with all of the values < 51999.");
3222 }
3223
3224 st.site = &k_emlrtRSI;
3225 p = true;
3226 if (!(varargin_4 < 0)) {
3227 } else {
3228 p = false;
3229 }
3230
3231 if (p) {
3232 } else {
3233 emlrtErrMsgIdAndExplicitTxt(&st, &ob_emlrtRTEI,
3234 "MATLAB:findpeaks:expectedNonnegative", 43,
3235 "Expected MinPeakDistance to be nonnegative.");
3236 }
3237 }
3238
3239 static void removePeaksBelowMinPeakHeight(const emlrtStack *sp, const real_T Y
3240 [52000], emxArray_real_T *iPk, real_T Ph)
3241 {
3242 int32_T loop_ub;
3243 int32_T i13;
3244 int32_T trueCount;
3245 int32_T i;
3246 int32_T partialTrueCount;
3247 if (!(iPk->size[0] == 0)) {
3248 loop_ub = iPk->size[0];
3249 for (i13 = 0; i13 < loop_ub; i13++) {
3250 trueCount = (int32_T)iPk->data[i13];
3251 if (!((trueCount >= 1) && (trueCount <= 52000))) {
3252 emlrtDynamicBoundsCheckR2012b(trueCount, 1, 52000, &o_emlrtBCI, sp);
3253 }
3254 }
3255
3256 loop_ub = iPk->size[0] - 1;
3257 trueCount = 0;
3258 for (i = 0; i <= loop_ub; i++) {
3259 i13 = (int32_T)iPk->data[i];
3260 if (!((i13 >= 1) && (i13 <= 52000))) {
3261 emlrtDynamicBoundsCheckR2012b(i13, 1, 52000, &o_emlrtBCI, sp);
3262 }
3263
3264 if (Y[i13 - 1] > Ph) {
3265 trueCount++;
3266 }
3267 }
3268
3269 partialTrueCount = 0;
3270 for (i = 0; i <= loop_ub; i++) {
3271 i13 = (int32_T)iPk->data[i];
3272 if (!((i13 >= 1) && (i13 <= 52000))) {
3273 emlrtDynamicBoundsCheckR2012b(i13, 1, 52000, &o_emlrtBCI, sp);
3274 }
3275
3276 if (Y[i13 - 1] > Ph) {
3277 i13 = iPk->size[0];
3278 if (!((i + 1 >= 1) && (i + 1 <= i13))) {
3279 emlrtDynamicBoundsCheckR2012b(i + 1, 1, i13, &p_emlrtBCI, sp);
3280 }
3281
3282 iPk->data[partialTrueCount] = iPk->data[i];
3283 partialTrueCount++;
3284 }
3285 }
3286
3287 i13 = iPk->size[0];
3288 iPk->size[0] = trueCount;
3289 emxEnsureCapacity(sp, (emxArray__common *)iPk, i13, (int32_T)sizeof(real_T),
3290 &l_emlrtRTEI);
3291 }
3292 }
3293
3294 static void removePeaksBelowThreshold(const emlrtStack *sp, const real_T Y[52000],
3295 emxArray_real_T *iPk)
3296 {
3297 emxArray_real_T *varargin_1;
3298 int32_T i14;
3299 int32_T k;
3300 emxArray_real_T *varargin_2;
3301 int32_T c;
3302 emxArray_real_T *base;
3303 int32_T i;
3304 int32_T partialTrueCount;
3305 emlrtStack st;
3306 emlrtStack b_st;
3307 emlrtStack c_st;
3308 emlrtStack d_st;
3309 emlrtStack e_st;
3310 st.prev = sp;
3311 st.tls = sp->tls;
3312 b_st.prev = &st;
3313 b_st.tls = st.tls;
3314 c_st.prev = &b_st;
3315 c_st.tls = b_st.tls;
3316 d_st.prev = &c_st;
3317 d_st.tls = c_st.tls;
3318 e_st.prev = &d_st;
3319 e_st.tls = d_st.tls;
3320 emlrtHeapReferenceStackEnterFcnR2012b(sp);
3321 emxInit_real_T(sp, &varargin_1, 1, &m_emlrtRTEI, true);
3322 st.site = &bb_emlrtRSI;
3323 i14 = varargin_1->size[0];
3324 varargin_1->size[0] = iPk->size[0];
3325 emxEnsureCapacity(&st, (emxArray__common *)varargin_1, i14, (int32_T)sizeof
3326 (real_T), &m_emlrtRTEI);
3327 k = iPk->size[0];
3328 for (i14 = 0; i14 < k; i14++) {
3329 c = (int32_T)(iPk->data[i14] - 1.0);
3330 if (!((c >= 1) && (c <= 52000))) {
3331 emlrtDynamicBoundsCheckR2012b(c, 1, 52000, &q_emlrtBCI, &st);
3332 }
3333
3334 varargin_1->data[i14] = Y[c - 1];
3335 }
3336
3337 emxInit_real_T(&st, &varargin_2, 1, &m_emlrtRTEI, true);
3338 i14 = varargin_2->size[0];
3339 varargin_2->size[0] = iPk->size[0];
3340 emxEnsureCapacity(&st, (emxArray__common *)varargin_2, i14, (int32_T)sizeof
3341 (real_T), &m_emlrtRTEI);
3342 k = iPk->size[0];
3343 for (i14 = 0; i14 < k; i14++) {
3344 c = (int32_T)(iPk->data[i14] + 1.0);
3345 if (!((c >= 1) && (c <= 52000))) {
3346 emlrtDynamicBoundsCheckR2012b(c, 1, 52000, &r_emlrtBCI, &st);
3347 }
3348
3349 varargin_2->data[i14] = Y[c - 1];
3350 }
3351
3352 b_st.site = &cb_emlrtRSI;
3353 c_st.site = &db_emlrtRSI;
3354 d_st.site = &eb_emlrtRSI;
3355 e_st.site = &fb_emlrtRSI;
3356 c = iPk->size[0];
3357 emxInit_real_T(&e_st, &base, 1, &ab_emlrtRTEI, true);
3358 i14 = base->size[0];
3359 base->size[0] = (uint16_T)c;
3360 emxEnsureCapacity(&e_st, (emxArray__common *)base, i14, (int32_T)sizeof(real_T),
3361 &y_emlrtRTEI);
3362 if (dimagree(base, varargin_1, varargin_2)) {
3363 } else {
3364 emlrtErrorWithMessageIdR2012b(&e_st, &qb_emlrtRTEI, "MATLAB:dimagree", 0);
3365 }
3366
3367 emxFree_real_T(&varargin_2);
3368 emxFree_real_T(&varargin_1);
3369 e_st.site = &gb_emlrtRSI;
3370 for (k = 0; k + 1 <= (uint16_T)c; k++) {
3371 base->data[k] = muDoubleScalarMax(Y[(int32_T)(iPk->data[k] - 1.0) - 1], Y
3372 [(int32_T)(iPk->data[k] + 1.0) - 1]);
3373 }
3374
3375 k = iPk->size[0];
3376 for (i14 = 0; i14 < k; i14++) {
3377 c = (int32_T)iPk->data[i14];
3378 if (!((c >= 1) && (c <= 52000))) {
3379 emlrtDynamicBoundsCheckR2012b(c, 1, 52000, &s_emlrtBCI, sp);
3380 }
3381 }
3382
3383 i14 = iPk->size[0];
3384 c = base->size[0];
3385 if (i14 != c) {
3386 emlrtSizeEqCheck1DR2012b(i14, c, &d_emlrtECI, sp);
3387 }
3388
3389 k = iPk->size[0] - 1;
3390 c = 0;
3391 for (i = 0; i <= k; i++) {
3392 if (Y[(int32_T)iPk->data[i] - 1] - base->data[i] >= 0.0) {
3393 c++;
3394 }
3395 }
3396
3397 partialTrueCount = 0;
3398 for (i = 0; i <= k; i++) {
3399 if (Y[(int32_T)iPk->data[i] - 1] - base->data[i] >= 0.0) {
3400 i14 = iPk->size[0];
3401 if (!((i + 1 >= 1) && (i + 1 <= i14))) {
3402 emlrtDynamicBoundsCheckR2012b(i + 1, 1, i14, &t_emlrtBCI, sp);
3403 }
3404
3405 iPk->data[partialTrueCount] = iPk->data[i];
3406 partialTrueCount++;
3407 }
3408 }
3409
3410 emxFree_real_T(&base);
3411 i14 = iPk->size[0];
3412 iPk->size[0] = c;
3413 emxEnsureCapacity(sp, (emxArray__common *)iPk, i14, (int32_T)sizeof(real_T),
3414 &m_emlrtRTEI);
3415 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
3416 }
3417
3418 static real_T skip_to_last_equal_value(int32_T *k, const emxArray_real_T *x)
3419 {
3420 real_T xk;
3421 boolean_T exitg1;
3422 real_T absxk;
3423 int32_T exponent;
3424 boolean_T p;
3425 xk = x->data[*k - 1];
3426 exitg1 = false;
3427 while ((!exitg1) && (*k < x->size[0])) {
3428 absxk = muDoubleScalarAbs(xk / 2.0);
3429 if (absxk <= 2.2250738585072014E-308) {
3430 absxk = 4.94065645841247E-324;
3431 } else {
3432 frexp(absxk, &exponent);
3433 absxk = ldexp(1.0, exponent - 53);
3434 }
3435
3436 p = (muDoubleScalarAbs(xk - x->data[*k]) < absxk);
3437 if (p) {
3438 (*k)++;
3439 } else {
3440 exitg1 = true;
3441 }
3442 }
3443
3444 return xk;
3445 }
3446
3447 static void sort(const emlrtStack *sp, emxArray_real_T *x, emxArray_int32_T *idx)
3448 {
3449 int32_T i15;
3450 emlrtStack st;
3451 st.prev = sp;
3452 st.tls = sp->tls;
3453 i15 = nonSingletonDim(x);
3454 st.site = &xb_emlrtRSI;
3455 b_sort(&st, x, i15, idx);
3456 }
3457
3458 static void sortIdx(const emlrtStack *sp, emxArray_real_T *x, emxArray_int32_T
3459 *idx)
3460 {
3461 emxArray_real_T *b_x;
3462 int32_T ib;
3463 int32_T wOffset;
3464 int32_T m;
3465 int32_T n;
3466 real_T x4[4];
3467 int32_T idx4[4];
3468 emxArray_int32_T *iwork;
3469 emxArray_real_T *xwork;
3470 int32_T nNaNs;
3471 int32_T k;
3472 int8_T perm[4];
3473 int32_T i3;
3474 int32_T i4;
3475 emlrtStack st;
3476 emlrtStack b_st;
3477 emlrtStack c_st;
3478 emlrtStack d_st;
3479 st.prev = sp;
3480 st.tls = sp->tls;
3481 b_st.prev = &st;
3482 b_st.tls = st.tls;
3483 c_st.prev = &b_st;
3484 c_st.tls = b_st.tls;
3485 d_st.prev = &c_st;
3486 d_st.tls = c_st.tls;
3487 emlrtHeapReferenceStackEnterFcnR2012b(sp);
3488 emxInit_real_T(sp, &b_x, 1, &u_emlrtRTEI, true);
3489 ib = x->size[0];
3490 st.site = &hc_emlrtRSI;
3491 b_st.site = &ic_emlrtRSI;
3492 wOffset = b_x->size[0];
3493 b_x->size[0] = x->size[0];
3494 emxEnsureCapacity(&b_st, (emxArray__common *)b_x, wOffset, (int32_T)sizeof
3495 (real_T), &u_emlrtRTEI);
3496 m = x->size[0];
3497 for (wOffset = 0; wOffset < m; wOffset++) {
3498 b_x->data[wOffset] = x->data[wOffset];
3499 }
3500
3501 wOffset = idx->size[0];
3502 idx->size[0] = ib;
3503 emxEnsureCapacity(&b_st, (emxArray__common *)idx, wOffset, (int32_T)sizeof
3504 (int32_T), &u_emlrtRTEI);
3505 for (wOffset = 0; wOffset < ib; wOffset++) {
3506 idx->data[wOffset] = 0;
3507 }
3508
3509 n = x->size[0];
3510 for (m = 0; m < 4; m++) {
3511 x4[m] = 0.0;
3512 idx4[m] = 0;
3513 }
3514
3515 emxInit_int32_T(&b_st, &iwork, 1, &eb_emlrtRTEI, true);
3516 wOffset = iwork->size[0];
3517 iwork->size[0] = ib;
3518 emxEnsureCapacity(&b_st, (emxArray__common *)iwork, wOffset, (int32_T)sizeof
3519 (int32_T), &cb_emlrtRTEI);
3520 m = iwork->size[0];
3521 wOffset = iwork->size[0];
3522 iwork->size[0] = m;
3523 emxEnsureCapacity(&b_st, (emxArray__common *)iwork, wOffset, (int32_T)sizeof
3524 (int32_T), &u_emlrtRTEI);
3525 for (wOffset = 0; wOffset < m; wOffset++) {
3526 iwork->data[wOffset] = 0;
3527 }
3528
3529 emxInit_real_T(&b_st, &xwork, 1, &fb_emlrtRTEI, true);
3530 m = x->size[0];
3531 wOffset = xwork->size[0];
3532 xwork->size[0] = m;
3533 emxEnsureCapacity(&b_st, (emxArray__common *)xwork, wOffset, (int32_T)sizeof
3534 (real_T), &db_emlrtRTEI);
3535 m = xwork->size[0];
3536 wOffset = xwork->size[0];
3537 xwork->size[0] = m;
3538 emxEnsureCapacity(&b_st, (emxArray__common *)xwork, wOffset, (int32_T)sizeof
3539 (real_T), &u_emlrtRTEI);
3540 for (wOffset = 0; wOffset < m; wOffset++) {
3541 xwork->data[wOffset] = 0.0;
3542 }
3543
3544 nNaNs = 0;
3545 ib = 0;
3546 c_st.site = &oc_emlrtRSI;
3547 for (k = 0; k + 1 <= n; k++) {
3548 if (muDoubleScalarIsNaN(b_x->data[k])) {
3549 idx->data[(n - nNaNs) - 1] = k + 1;
3550 xwork->data[(n - nNaNs) - 1] = b_x->data[k];
3551 nNaNs++;
3552 } else {
3553 ib++;
3554 idx4[ib - 1] = k + 1;
3555 x4[ib - 1] = b_x->data[k];
3556 if (ib == 4) {
3557 ib = k - nNaNs;
3558 if (x4[0] >= x4[1]) {
3559 m = 1;
3560 wOffset = 2;
3561 } else {
3562 m = 2;
3563 wOffset = 1;
3564 }
3565
3566 if (x4[2] >= x4[3]) {
3567 i3 = 3;
3568 i4 = 4;
3569 } else {
3570 i3 = 4;
3571 i4 = 3;
3572 }
3573
3574 if (x4[m - 1] >= x4[i3 - 1]) {
3575 if (x4[wOffset - 1] >= x4[i3 - 1]) {
3576 perm[0] = (int8_T)m;
3577 perm[1] = (int8_T)wOffset;
3578 perm[2] = (int8_T)i3;
3579 perm[3] = (int8_T)i4;
3580 } else if (x4[wOffset - 1] >= x4[i4 - 1]) {
3581 perm[0] = (int8_T)m;
3582 perm[1] = (int8_T)i3;
3583 perm[2] = (int8_T)wOffset;
3584 perm[3] = (int8_T)i4;
3585 } else {
3586 perm[0] = (int8_T)m;
3587 perm[1] = (int8_T)i3;
3588 perm[2] = (int8_T)i4;
3589 perm[3] = (int8_T)wOffset;
3590 }
3591 } else if (x4[m - 1] >= x4[i4 - 1]) {
3592 if (x4[wOffset - 1] >= x4[i4 - 1]) {
3593 perm[0] = (int8_T)i3;
3594 perm[1] = (int8_T)m;
3595 perm[2] = (int8_T)wOffset;
3596 perm[3] = (int8_T)i4;
3597 } else {
3598 perm[0] = (int8_T)i3;
3599 perm[1] = (int8_T)m;
3600 perm[2] = (int8_T)i4;
3601 perm[3] = (int8_T)wOffset;
3602 }
3603 } else {
3604 perm[0] = (int8_T)i3;
3605 perm[1] = (int8_T)i4;
3606 perm[2] = (int8_T)m;
3607 perm[3] = (int8_T)wOffset;
3608 }
3609
3610 idx->data[ib - 3] = idx4[perm[0] - 1];
3611 idx->data[ib - 2] = idx4[perm[1] - 1];
3612 idx->data[ib - 1] = idx4[perm[2] - 1];
3613 idx->data[ib] = idx4[perm[3] - 1];
3614 b_x->data[ib - 3] = x4[perm[0] - 1];
3615 b_x->data[ib - 2] = x4[perm[1] - 1];
3616 b_x->data[ib - 1] = x4[perm[2] - 1];
3617 b_x->data[ib] = x4[perm[3] - 1];
3618 ib = 0;
3619 }
3620 }
3621 }
3622
3623 wOffset = (x->size[0] - nNaNs) - 1;
3624 if (ib > 0) {
3625 for (m = 0; m < 4; m++) {
3626 perm[m] = 0;
3627 }
3628
3629 if (ib == 1) {
3630 perm[0] = 1;
3631 } else if (ib == 2) {
3632 if (x4[0] >= x4[1]) {
3633 perm[0] = 1;
3634 perm[1] = 2;
3635 } else {
3636 perm[0] = 2;
3637 perm[1] = 1;
3638 }
3639 } else if (x4[0] >= x4[1]) {
3640 if (x4[1] >= x4[2]) {
3641 perm[0] = 1;
3642 perm[1] = 2;
3643 perm[2] = 3;
3644 } else if (x4[0] >= x4[2]) {
3645 perm[0] = 1;
3646 perm[1] = 3;
3647 perm[2] = 2;
3648 } else {
3649 perm[0] = 3;
3650 perm[1] = 1;
3651 perm[2] = 2;
3652 }
3653 } else if (x4[0] >= x4[2]) {
3654 perm[0] = 2;
3655 perm[1] = 1;
3656 perm[2] = 3;
3657 } else if (x4[1] >= x4[2]) {
3658 perm[0] = 2;
3659 perm[1] = 3;
3660 perm[2] = 1;
3661 } else {
3662 perm[0] = 3;
3663 perm[1] = 2;
3664 perm[2] = 1;
3665 }
3666
3667 c_st.site = &pc_emlrtRSI;
3668 if (ib > 2147483646) {
3669 d_st.site = &w_emlrtRSI;
3670 check_forloop_overflow_error(&d_st);
3671 }
3672
3673 for (k = 1; k <= ib; k++) {
3674 idx->data[(wOffset - ib) + k] = idx4[perm[k - 1] - 1];
3675 b_x->data[(wOffset - ib) + k] = x4[perm[k - 1] - 1];
3676 }
3677 }
3678
3679 m = (nNaNs >> 1) + 1;
3680 c_st.site = &qc_emlrtRSI;
3681 for (k = 1; k < m; k++) {
3682 ib = idx->data[wOffset + k];
3683 idx->data[wOffset + k] = idx->data[n - k];
3684 idx->data[n - k] = ib;
3685 b_x->data[wOffset + k] = xwork->data[n - k];
3686 b_x->data[n - k] = xwork->data[wOffset + k];
3687 }
3688
3689 if ((nNaNs & 1) != 0) {
3690 b_x->data[wOffset + m] = xwork->data[wOffset + m];
3691 }
3692
3693 wOffset = x->size[0] - nNaNs;
3694 m = 2;
3695 if (wOffset > 1) {
3696 if (x->size[0] >= 256) {
3697 ib = wOffset >> 8;
3698 if (ib > 0) {
3699 b_st.site = &jc_emlrtRSI;
3700 for (m = 1; m <= ib; m++) {
3701 b_st.site = &kc_emlrtRSI;
3702 merge_pow2_block(idx, b_x, (m - 1) << 8);
3703 }
3704
3705 m = ib << 8;
3706 ib = wOffset - m;
3707 if (ib > 0) {
3708 b_st.site = &lc_emlrtRSI;
3709 merge_block(&b_st, idx, b_x, m, ib, 2, iwork, xwork);
3710 }
3711
3712 m = 8;
3713 }
3714 }
3715
3716 b_st.site = &mc_emlrtRSI;
3717 merge_block(&b_st, idx, b_x, 0, wOffset, m, iwork, xwork);
3718 }
3719
3720 if ((nNaNs > 0) && (wOffset > 0)) {
3721 b_st.site = &nc_emlrtRSI;
3722 c_st.site = &bd_emlrtRSI;
3723 if (nNaNs > 2147483646) {
3724 d_st.site = &w_emlrtRSI;
3725 check_forloop_overflow_error(&d_st);
3726 }
3727
3728 for (k = 0; k + 1 <= nNaNs; k++) {
3729 xwork->data[k] = b_x->data[wOffset + k];
3730 iwork->data[k] = idx->data[wOffset + k];
3731 }
3732
3733 for (k = wOffset - 1; k + 1 > 0; k--) {
3734 b_x->data[nNaNs + k] = b_x->data[k];
3735 idx->data[nNaNs + k] = idx->data[k];
3736 }
3737
3738 c_st.site = &cd_emlrtRSI;
3739 for (k = 0; k + 1 <= nNaNs; k++) {
3740 b_x->data[k] = xwork->data[k];
3741 idx->data[k] = iwork->data[k];
3742 }
3743 }
3744
3745 emxFree_real_T(&xwork);
3746 emxFree_int32_T(&iwork);
3747 wOffset = x->size[0];
3748 x->size[0] = b_x->size[0];
3749 emxEnsureCapacity(sp, (emxArray__common *)x, wOffset, (int32_T)sizeof(real_T),
3750 &u_emlrtRTEI);
3751 m = b_x->size[0];
3752 for (wOffset = 0; wOffset < m; wOffset++) {
3753 x->data[wOffset] = b_x->data[wOffset];
3754 }
3755
3756 emxFree_real_T(&b_x);
3757 emlrtHeapReferenceStackLeaveFcnR2012b(sp);
3758 }
3759
3760 mxArray *emlrtMexFcnProperties(void)
3761 {
3762 mxArray *xResult;
3763 mxArray *xEntryPoints;
3764 const char * fldNames[4] = { "Name", "NumberOfInputs", "NumberOfOutputs",
3765 "ConstantInputs" };
3766
3767 mxArray *xInputs;
3768 const char * b_fldNames[4] = { "Version", "ResolvedFunctions", "EntryPoints",
3769 "CoverageInfo" };
3770
3771 xEntryPoints = emlrtCreateStructMatrix(1, 1, 4, fldNames);
3772 xInputs = emlrtCreateLogicalMatrix(1, 3);
3773 emlrtSetField(xEntryPoints, 0, "Name", mxCreateString("matlabfindpeaks"));
3774 emlrtSetField(xEntryPoints, 0, "NumberOfInputs", mxCreateDoubleScalar(3.0));
3775 emlrtSetField(xEntryPoints, 0, "NumberOfOutputs", mxCreateDoubleScalar(2.0));
3776 emlrtSetField(xEntryPoints, 0, "ConstantInputs", xInputs);
3777 xResult = emlrtCreateStructMatrix(1, 1, 4, b_fldNames);
3778 emlrtSetField(xResult, 0, "Version", mxCreateString("9.0.0.341360 (R2016a)"));
3779 emlrtSetField(xResult, 0, "ResolvedFunctions", (mxArray *)
3780 emlrtMexFcnResolvedFunctionsInfo());
3781 emlrtSetField(xResult, 0, "EntryPoints", xEntryPoints);
3782 emlrtSetField(xResult, 0, "CoverageInfo", covrtSerializeInstanceData
3783 (&emlrtCoverageInstance));
3784 return xResult;
3785 }
3786
3787 const mxArray *emlrtMexFcnResolvedFunctionsInfo(void)
3788 {
3789 const mxArray *nameCaptureInfo;
3790 const char * data[54] = {
3791 "789ced5ddd8f24b771a77c3a598225cb70627dda71d60904cb426ea43be9743ad9d2ecddee7ad7ba3d6d74275bc149187167383b8ded61b7bb7bee560e020f12"
3792 "07d0a35e0cc40102e8312ff903f2622402e227bf39861103f94210c0af0102e50ccb40c8eee99d692e67c86eb23f66b60698dbad3d925564fdbaba582c92e89e",
3793 "9d5dc43e9f65dfc7deff14ba8ffdbc9f7d3f8592cfd9097d0ffbfee7e467f2f77bd14313facfd9b7ebd1881c45c97f523c2428fdf4bca143318d6ebee7131490"
3794 "d0736f935efc3f7dc725379d21b9e6cd10db0e23865b33ff754cf0ff0a06e171cbc89d25920fefc707ec9bf6e35e493fde99e9c7e726f4adcdefbc73f572ebcd",
3795 "900461ebd2c5e72e5d6a6d90f030f2fcd6db47e485b78f70ffeda3fdfde4f7fd0becfb2cfbfd45f677f2f6d14bec27b998fcfda5175a431cb978bfefd09e4ff0"
3796 "61786e3891abad90eb0141ae07e26199b432d3bf4b8a76ce0aed70daa1d185f393faef2aea3f2bd4e7f4ad9db736dfd9b8dcda8dfbd68a3ccfddf78e5aa17340",
3797 "b19bfe98e9b228e77d123ef7ccf07960f277ceea7fbffff37583fad271aaa3fe5767eadf23a98f667e1629efa3c57afc06caea91d379f5b8e6e320241d87faa3"
3798 "289cf0dd56f0fdbcc097d3b7b1ebf47044701405cefe2822e1b41fcf2adabb37d3debda84b5c57a7ff6d418e76dcff6bd2012043b7e53afb9367b7e5627ad03a",
3799 "29b309aec7bffc8802ae6de0ba8dcad16b6e1c0e7060526fa0a8f7bcd0cfe7f5fb1946417f445b9c53fcfa31d0fb78ff0201dc36d91e17f207c2c0bba359ff3e"
3800 "a13ea77bde68df2549fd12714c5cf64b2b16d614c7e8374f3f0e385e351c773dd7a39af54d717c5ea87f1e69e3d8f3c3562c6a8262237bfc09e058af7c9dfa04",
3801 "fc027e115a2efcee29f87d59e0c7e9aed723c1398746246016fe9c135e19396eb443af8f862470ba56707da4a87f55a87f55310efcfb4c2c78eb9954f29628f9"
3802 "64600c70f2d8c73ffd67c0b94679957ed75156bf9cce8ff33527ecf45da6ef4e6a7365e323e37fbfc09fd34ec89c19272255d8ed1785fa2feaf73ff59f136119",
3803 "a6c17faedf6edbd627d86db0dba701e7c5e21c0eed4bc6b3a1710e262cc439d2fa75e3d7b63ec14e839d6e22ce9b61a729ae2a0e62e1b966c2829d4eebd78d5f"
3804 "dbfa043b0d761ae22027f9cbec76dff5bc40b37ead769b2f87c7c21adbed87befa14d8eddaedb6449f60b7c16e03ce117a52e0c76901e76117bb3838975a6f75",
3805 "1e5efa996d37ad673b5f4b8aef671291d3b130587ffc18fcee66e2fa5d05bfa7057e9c16708d7ddf7def468c94ad11ed468e4777e89e8bbb64a65f6d059f8705"
3806 "3e9cee4f5aeb0c30ed31c3cedb192bdad915dad9558c8f14f7f37b749c575e10473ffec905780e74ca8f5133f45c96dd37f56fc0feaf26ee557eeb1594d52ba7",
3807 "0bcc47bb03d23ddce233d237303d2053fedb0afe8f0afc392dc5fbe64125387f59a8ffb2623ca4384f2536f7dfef7ef43ae05ca77c5d7a6d2bf83e24f0e5b413"
3808 "d2647e17f1ed74d5d8efcb42fdcb8afef3e7bcef1c919eefb1eeb732229be70fa25f83fd6e36ae8be653b177c3a08a38e20b42fd1714fd3e81e7445453ff1b70",
3809 "ac59be92f8d914c76b7d2708a3be73cc5fe577ff9ec09fd38c4787c7d8fb5ec01c56bfe3dd2601735def74626fc72cde3256c8f39a50ef35c578cccecb93e159"
3810 "20bab15f3286754fcdf27f8b16ebf9bb28ab674e5bd4f3dae2029d01717d12ccc89b771f2437a496fc7c87f6c8d10e8db4ecff73427bcf698c9b60ff533706ec",
3811 "3faa3f0e695b9f6d053f5dbfbce8be60f0c75713c7cb66cf8bf8e1acfd213e32c37f19fe7b36df2716d2d47f073f46b3fc69c1bd439700f70e05dca3d3316f2d"
3812 "ea8f971d7f01ffdb6efdba715cf63a509178629ce1c85ef265da63e3bcf95448d897d98879a46d7daae2868f0bfc382dc435989b82a35df63777a61f65cd2be5",
3813 "e7bae47c1f4d2536f433609d7e59ecb30a8f6732fccf20bc1f5a59b7543dcf06e76324f9694c500be79d3c08f9e276ecb36d7d42be38e48b03ceb5fc9049de20"
3814 "b7dcd376cbca177f45a8f78aa2ff0bf30527636160bffff5ef2e83fd6e22aedf52f0fb8ac08fd3ea7cf169fb6d45fbba79e22a7bbe25b4b3a51817ddfc6143dc",
3815 "ff02f2c3edf8df65ebb72cfb5e765e21d8f9e5c4bbed38c2a2f96630996aeae0f1d3025f4e0704bb7c41b2cc38e04581ef45fdfe2671a3899066f88538a02d3f"
3816 "c5b63edb0a7e9f11f8719aaf59a6d84de52e8adfa2f3c93ded0efb81731b47a43523b5f97c12f0ac59be6efd429c1be2dc4dc0b9a5383707f98903528aae430e",
3817 "839e73dbe955724eac417e08ef7f2aea395fd2df1c7878b0fd61ad78feadade7a96e3fa44c7d6afbcf491b95acd7189c27c0fb9b76d7f4be9b3ffd9f3db0c736"
3818 "f06b5b9fb05e03eb358073847e5fe0c769493c8f1cf957bda18f238721b50a9c6f08f53714e330379f3123b9f1796dff07fe753371beade027bb4752c0396b52",
3819 "3ebe65f82779e342527c33890de3d421f8277ae59b3e5f3c2bf0e7349ca709785e563ccbf008fbc1b4eb4bc77915715c2c3e6b7ebf645bc1f773025ffeed0e0e"
3820 "e3367a38c27cbf6c15ebe26da17e3be9bf345c9f1d80344e2f4a6d745eda7dfffd37304f6c32ae55f3c52704be9ce6463e698afd8b878479a7d34625e3ad8bf3",
3821 "300a46dd48ef7df54da1fe3751ee7d9ff22e18eda781f3496cf92365eb5795fff707027f4e0bf3c7b8fdbdb4f99de903d044fc4be793b21e98ed27fbd99bef00"
3822 "fe75ca7f8016ebf71d94d52fa72de9776dfa4850f633ecb0e7a63b407a71954704b9382d3c179177cdbbc337c597b90e9ff71c13e9f84c24b5708e09c40935cb",
3823 "d7e5e7a8702d3b278abf440e4834f30ab98ddd51f1f5cc1103de85f3e5c4c325ef3f89e8c6eb9be0df6896af5bbf16d68158fbc7ef8e6ff3d69b887ba95d3f21"
3824 "b931ee21cf4ab37c93f40b71c6e4037146fb7e4a1b65f5c9694d7dba981eb498b9767a3822388a02677f1491f0649c4d374f70f63ef9a2fb2a55f8857be4edd6",
3825 "5f363bac83df35ecbab2f12982e3b2d72f01cf76eb978de7315aaccf1d94d527a78df14cbd28bd5b58364ebaebf2703f31e0ba28ae0dce639f8f6b7eb77c440e"
3826 "02ec4ac709ec35e01aa1d3816b99bd863c2ac0f5bcf24dcd3ff9acc097d3e93312b247841e148c6f10d7d5e9f7d705fe5f47c59ee74456e378ddabffe8039e75",
3827 "caabe6895b28ab574e9be895d9680e29469af8d3817707951bafb3e0473321c18f4eebd76d97abb04f80dfe403f85d023bcc570f27891f3aeb85704f592eff03"
3828 "70af595e85fb4d94d533a70dfd0f0cf94ed3f1877ca726fa2539e78bcc96afbbee1ea764e3a2ef9738b4af59bf01716a262cf82769fd55c5715e7bca9bd3c1af",
3829 "ecbc12d73b70bad8d5c2ef05a1fe0594f7be0726a8b99ff1a3e709e0b73cfce6d667b20192fd9af255f9171af793a6b73469d96515ae55e350c5bdde39f071f7"
3830 "a3d701df36f05d965edb0abebaf79d968d6bb8f714705dd45ee5590f67af824115fe47917c52e11e3c2eaa693e29e058b3bc2aceb1acf7399ae218ee73b45bbf",
3831 "6e7b5c961f0df169884f9f26bc6f2bf83e26f0e5b4785e25ed91a33d7714da88e7d91e07f93995a9c4c671bda77e15c2b9234dc677117b2ec3f78d01f6c95573"
3832 "7baef2cff29e8f351fdf53892dcc23efaedf023b6e03e76d94d52fa773c7aff9efd73ce6faeee22336bd2aba0e931e9d56c53a8cc1bd6a33e7be4dc7b9a03ff2",
3833 "09f823ab8763d8f702386e1a8e613d71a11d86f544cdf2cb82df9ed3ef57617f0dce37e0074df29d2c5c548847a36af05bb53e55f33db87f23174ee0fe0dcdf2"
3834 "55e37c5bc1cf76be8769dc0ef23d00d73ab87e4bc14fe3bcd4ae47c3e8ba476f38f4c0259147371cfdf576533b6ee5bc54590fccce0b8673c534cb578d77959f",
3835 "7d26c3ef0c1a3ad496fd8fa3c43b342a3bee91f69b896e1cf7f8877fdf071cdbc0b16d7daaf0a8b18e487170e0d0eee0b0ccf5953cf6391ce080f45a89759ed8"
3836 "68d1541f0b6d669fffebe137c0cfd629df24fdc2391f73f100e77c68966f9a9dd6f01b587baf07bbf8a850be9fee3e442bf3c55452f3f9e21fbdd0033ceb94af",
3837 "4bafe07f80ffd104ff631b65f5cb69037cc7f94ce4280ac87034049c03ced3fa65e37c8c16ebf71acaea97d3a638df77e831d653392cf82b9938b785f6327113"
3838 "887baf26fe977d9f63d538877d8f80f32af73ddac6f740d11eec83b45bbf6e3fbda9fb20abc635ec8bb45bffb4f8e5aa3cab270539382df1cbc991bfeeba5ef7",
3839 "b87f55fb2daf0aedbd5a64bc667b6276ee3b9c77a659be2ebdaaf253be22f0e5f402dc5ff7267bcad27ed9c6bfea3db825b4b7653a4e931ef19782419ce63fae"
3840 "df0bcf814ef9f7d162fdde4059fd72daf47d90b83d275e0b10af8178cddcfaa7ed39282b0fbdeaf703e4a52ff77331408bf5dbc0bc743ff07aa1f3bde2f75f57",
3841 "9e979e4a6c8eeb5b773700d74dc4359c0b04e70235719edb46593d73ba8efd9fbc551bf65af55c1bed5fe64f3517d4dc4e437ea366f9aaf509fb3fc1cf069c23"
3842 "f484c08fd3d238cb39def0b41f45fd914ae2b1cf2422a76361e07fc07e38cdf255e3fa5d05bfa7057e9c16708d7ddf7def468c94ad11ed468e4777e89e8bbb64",
3843 "a65f6d059f87053e9cee4f5aeb0c30edb944cb0fdf15dad9558c8f14f7f37b649a4ff0e39f5c80e740a7fc183543cf2abbff25410e4e0bcfc728247b386033bb"
3844 "ab7c9b312a96af90eee350f935eb823ceb45c6252bb1857c83f10f7ef835c0bd4ef9baf5bbade0af91ef7edc7a99fe8d9573698f2535be9778f3fb7f01f85e25",
3845 "bb0ef145882f9e66fc179dcf96bd7e04f3dae5c47d5d71f522761ece234f3eb37931701eb91dfbfe2d94d52fa773e33c2043f6028fefd3bc42d85bfce62020e1"
3846 "c0737b533954f3cb13e71c4dce1768f07919c7e72ba41bd10df000e71a6996af5a9fdb0a7eb0df7aa13f02fbad35cb370dd7700e8c140f700e8c66f9315aacd7",
3847 "653d3f6029f21121fffcd4e2bdac7d794b1147817d7895e37e55f7e1959defb525d4df321d17d87797a95f36eedf478bf5fb1d94d52fa7ede8776db2ed88fd07"
3848 "a6a1e351583f82f5a3b9f5ebf67b765056cf9c36b4ff6be4bb23ecc63b84a67200fe01ff4dc47f53fc7ec80bd3c23de48569961fa3e5c03dd87db0fb75f8ffcb",
3849 "7eee06c43901f7cb807bd8ef07fbfd9a18f7fc06caea97d3b9f36abade90813e49ac918c8b8cef59812fa747944789ecc435078afae785fae791b67fe3f9612b"
3850 "16d5427ed86fc18fd12b5fb53edb0a7e0f08fc381dbf0348e4f9337297956f306fbd624fb3c37ee0dcc611691dcb6c963f73eb02dc936ec51e97a557f03fc0ff",
3851 "6862fc655e9cc100ef6b3e0e42d2e9bbf820948e93b63fe2fb24bd0fafa81d57bdb70cce7f0aa380a7cbc5529aeeaffe25d86f3b7e886d7d6e2bf8fdaec08fd3"
3852 "f1b310050e3de84401a661df0b8ee39065c5c93704393672f75b26b5f1fed2672fec00ae75cad7ad5f559ecc1f0afc392d9ea7118624886eb0e7c70b22d2bb11",
3853 "f34adb2f0bf7db825cdb8a7191ef3b94497e6e6880fba700f776705fb67e55f61df66d2cc439ecdbd02c3f468bf5bb87b2fae5b42d9caf399419fc03a283f747"
3854 "0439382de09d9b66beedce68fd53350fcf7b4f98743c26925a88137e0becb95ef926e855370ec2dad3c2714df34be2b25f5a8990a6f34b58afd72c3f46cdb0d3",
3855 "90af02f92ae08f9fe40ffe09f82765e2bbec380be01bf0bdcaf82eb2ced3f5dce3bc93bc7e38c3daa50af2136211cd713cfe04fc10bdf275ea13709b7c00b7cd"
3856 "c76d59792545f10cf92480efbaed72dff5bc40b3be2c2e58d1b970c9bd06b1b0c6e7c2c13d439ae58be563e7c5ef5a1cb68a83799271c9139f76e812c4a71d0a",
3857 "f16904f895e117d65700bfb3e5c768b13e5f47597d72ba007e27eb09e480049df86f9d9e13fa3862b80ec01e23c033e019ec33e0f964f9316a069eb7157268ac"
3858 "9338217e931166f1b94ad64926925a88d39dfdb731c4311a84f32cc65d420fa241877a9492839e56fcee8b821c9c16cfe3a17c4b30e95d757118a6fd2b6bdf63",
3859 "5b90a7ad1817f9793cb3129be459c3f99bcb8677f053c04f59253c839f027e0ae05c6b9f4c7cbbd39e3b0a6daccba8f06ee59ecd63898dd7679efa550878b781"
3860 "77833c6371fe99f8a0d969e8b11c907f0df9d7a7317fafa87f5d56fe93c1fafaa4bf5c42e37decfb703e831dfb2dbf47d0ecbc919ed7b94dba911784533954fe",
3861 "0a9c73b9102f70cea566f9315a0ebce7f5cf2d3c3f717b3b6c620bfe3ae09f7fcac4bfca3edf2fc8c169270ce3fd6755d8f79784fa2fa1dcf732a6e25a38bf1e"
3862 "fdfc3cf8335ae5ebd2ab6afef9b8c097d332fbbbebd0513867bccbc079defcb3f9763c96dc349e0e765cb37c53710e711688b3ac12de6dfbe91047077c2f13be",
3863 "bf20f0e5b4187761ad5edb948c7313fc7279dc2596d8865f0ef92c9ae5c768b15ef3ae8b2ed46bb25cc4880e0ebb84f678ec9c014c07efb2f36105bc07c44d8e"
3864 "ace7edb515ed3d2cb4c769f6307623c7a39d01a6bd895c03453b9784762e15199f5872c8df3a4d782fb21fd30929a692716edc7ecc388f8b0b6beca7801fae59",
3865 "7e8c16ebb329f1730d3b4e8220de765c6a9ea215bb1d4b6a74bef13fbd0cf143adf2efa3c5fa7c0b65f5c969537c87878edf89bc8e8bc3a8135f82dcb98ddd91"
3866 "d6f9af30ff5c881b987f6a965f36dcebcc4b719f6c7e5732fecd9d97c612c3bc74a67ed9b8af4bafb9f3afc2be53853ffe9c50ff39457ff963de778e48cff758",
3867 "775b5c4c1bf8fd35e077b9f17b26c3f70cc2fb6125f34983f38c92f37d98a016f64b3c08e7fb341bbf45f24f8641cfb9edf448153836d8dfc6ddad54d473bea4"
3868 "bf3970f060fbc35a716cedbed755c5715e3b4cfc25b0c33caec704b5700ef1fd7fb2017658a77cd5fa54e5917c49e0c769617e37c43472c21077e8be13a5f768",
3869 "178de3a9f671ac0bf2ac2bfa2f7d7eb3125bf093c71f839fac57be6efd5ac80fecbb1e8e76d9dfdc9976cb3a37c24a5ee05462c3bc40c07953ed785bc1ef3302"
3870 "3f4ef3186040b01b1fce86cab5dbf3ce2fd6895b261d9e8d5c4ea436dfaf03eb8d9ae5ebd62fd86db0dbab68b7b715fce6dd933d79423a3d42bd6088ddb4bda2",
3871 "781e2bea5d13e4b8862c3cdfc7d243de485abf6c7c8f5133f40cf61cecf92ada73588f59885b588fd12c5f356e8bed03ee3bd4892a59877951a8ff62defea6c2"
3872 "1adddb0e7e4653f1abf2a33f2ff0e3b4e04f24c9d6486dc7d3cf6c7bbafdbe28d4bba8e8b7d48f98645a1be060f097d7201f4fa77c53d7c5cf0a7c39ed840eed",
3873 "6bd637b5c716f60b306161de97d62f1bc763b4589f4dd92f00f9a40bf102f9a49ae5c76839f00efb0616e205f60d68961fa3e5c0bbee3ef69b92716fae7d8f25"
3874 "06fb3e537f35fcf2937a55e11bf6ad03be9719dfb04f1de69d3671fc015aaccfb751569f9cbeb52355273f779e8336f9d1674ea64ff021f331d7f8ef7bfcf71b",
3875 "c4c70173537a57dedbf502729319c85d87f2ffda70c208d32e918d9b2eced393ee1bbe5ea3bc0f5c1f27e34f00e77ae555f9519b28ab4f4e17b87f215e41cedc"
3876 "3622191fb0db60b7115a6e3cabfc6c9beb39f7a0e2e78ac07a8eddfaab8e6b58d7013b7ddaf1cc1a8b0f7c6a3c9e79de532cac319e1f82bca7e5c033e4ef2dc2",
3877 "01e4efad2a8ed3fde865f9c9b00fdd6efdb2f15bb53e55fb019e14f871fac47dc05bfc6938becedd08cfaaf8fbab823caf2afa2f5f279f91d8282f15f6033415"
3878 "d72abfe0d3023f4ef33576537b5c14bfc5f6f9249d86f95efdeb8265e915f66b19f9cd609f35cbdb5ef79ee3370ff1119fb94df9c2bc6f217e61dea759beee79",
3879 "5f113c327bc79e8772d7490cced19bc49563214defb5033f43b37cdd3856f91b5f14f8737ace3dba6fcce6db15ddd73556c893e77ebb903d33a4d74abc8d89cf"
3880 "214da14e8537bfdfeeef9fa4807b9df21fa2c57aa628ab674e5bd473fa40f088007b2c68841d1a76d24293d006f8e3e08fa7f5cb7e1efe0a2dd66b1765f5ca69",
3881 "9bcf83137678c21fe9890f8164fcf2f83bfcc8b3c6fb3b9313b0c0dfa9dfdfb982b2fae474017f870755667c9e297f0bf61ceead86fd622b83f72704fe9c96e1"
3882 "7d233e5e5d3eee65e0fd15a1fe2b8a71998ff74472c3bc3fc0bb66f9a6e31dee6bcfe5bf835fa359bee9b8d7f56b6e3a43b29c7e4d2c39f835e874e07d5bc1ff",
3883 "31813fa7e1bc07c0f9b2e1bcacf9aaeaf9795468f7d139edeed008e6af35d62f1bff4ddd579c379ec8b7e057914760108fece108f34c022eaa29be7f761eeebf"
3884 "d62a5fb53e55f6fccb023f4e9fc8bfbd3272dc68875e1f0d49e074adf8e9aaf7dcbc7b2772e6e1662537bf57e4b18f7f0a76bc893857f917bf23f0e3b4e47c2a",
3885 "e9f89661b7f39e7b3cf79c17b3fcf27ff96b88b758c1b36d7d16892b8afbe43d7ac3a1072e893cbae148e2d165d8edbcf313f9bef9ace416f21c212f40b37cdd"
3886 "fa85783ac4d34f837d077f05fc9555c2b3ca6e6bdc378cc39004d1b7b1ebf46277a594b8a1eafdb62eb4b75e645cb23d817b8867ead7edbf94addfb2e22d553f",
3887 "07107f81e7c0969d2b727e906dbcabde87709e90ddfa75fb37b6f509761dec7a13703f468bf5bb8bb2fae5747ebbeefbee7b37bad8c5c1d6e44cfa1dbae7e22e"
3888 "d15e57d238d7258c199c4bad7e3d79026da1bd7691f17a26e94a6a33c0cf07ff46166f81fdd8daf5a5e3bc8a3856e9b3eab8a3867d4d8cdde68195b8a3ca3ebf",
3889 "2cd47fb950ff27129bfb29773f7a1d70bda2b8f603af173adf23cb83eb5462735cdfbabb01feb74ef9baf40aeba2b02e7a1aec38e01c707e1a70aef2571e11f8"
3890 "715ab2febfd33bb2b3feaf7aaf5d16ea5f2eda7f26b185f39e37ff0cce7bb6e2af94a557f0c7c11f5f657c5bc8771985640f07eccd7fd5a36184cce28295c443",
3891 "b312dbc86bf9c10fbf06765ca7fcfb68b17eff1865f5cbe9e2385f73a81339d865b66c721578e738dbd09a7d873862f1faa6fcadd52f1bf72abbb689b27ae5b4"
3892 "01ee87f890748eee78c121029c03cea7f54f9b7d87380cc461e0392896c708f72f03bee7951f23bb764c81ef7dd7eb1e76862438209dcc7e21b0ef60df4f01fe",
3893 "13e4fbde9df39df851389603fc7af0eb4f13dec1de83bd6f627cbe8db27ae6b429fe01ef80f779f5cbc6bb2a5eb985b27ae6b4b1bd9f987ac03de07e5efdba71"
3894 "6f394e1f0e9c7ed4b98eaf8708700fb89f5fbf6cdc7f8016ebb9aef34ab715727d41908bd3c2fc36736f5fd1e740e5ffe5bdf7556a1712496de423fce617af01",
3895 "ee6dd87bf9396139717f4888bf1eed7a6174dd8ff13fe50ff8067caf32be8bf833b27dd03706d82757cdfd9962e351e4bcf5a9c416f284efaedf02bcabcaff3f"
3896 "9058d95a", "" };
3897
3898 nameCaptureInfo = NULL;
3899 emlrtNameCaptureMxArrayR2016a(data, 165928U, &nameCaptureInfo);
3900 return nameCaptureInfo;
3901 }
3902
3903 void matlabfindpeaks(matlabfindpeaksStackData *SD, const emlrtStack *sp, const
3904 real_T Yin[52000], real_T minpeakhight, int32_T
3905 minpeakdistance, emxArray_real_T *peaks, emxArray_real_T
3906 *locs)
3907 {
3908 emlrtStack st;
3909 st.prev = sp;
3910 st.tls = sp->tls;
3911 covrtLogFcn(&emlrtCoverageInstance, 0U, 0);
3912 covrtLogBasicBlock(&emlrtCoverageInstance, 0U, 0);
3913
3914 /* matlabfindpeaks */
3915 st.site = &emlrtRSI;
3916 findpeaks(SD, &st, Yin, minpeakhight, minpeakdistance, peaks, locs);
3917
3918 /* 寻峰及对应波长 */
3919 }
3920
3921 void matlabfindpeaks_api(matlabfindpeaksStackData *SD, const mxArray * const
3922 prhs[3], const mxArray *plhs[2])
3923 {
3924 emxArray_real_T *peaks;
3925 emxArray_real_T *locs;
3926 real_T (*Yin)[52000];
3927 real_T minpeakhight;
3928 int32_T minpeakdistance;
3929 emlrtStack st = { NULL, NULL, NULL };
3930
3931 st.tls = emlrtRootTLSGlobal;
3932 emlrtHeapReferenceStackEnterFcnR2012b(&st);
3933 emxInit_real_T(&st, &peaks, 1, &x_emlrtRTEI, true);
3934 emxInit_real_T(&st, &locs, 1, &x_emlrtRTEI, true);
3935
3936 /* Marshall function inputs */
3937 Yin = emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "Yin");
3938 minpeakhight = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "minpeakhight");
3939 minpeakdistance = e_emlrt_marshallIn(&st, emlrtAliasP(prhs[2]),
3940 "minpeakdistance");
3941
3942 /* Invoke the target function */
3943 matlabfindpeaks(SD, &st, *Yin, minpeakhight, minpeakdistance, peaks, locs);
3944
3945 /* Marshall function outputs */
3946 plhs[0] = emlrt_marshallOut(peaks);
3947 plhs[1] = emlrt_marshallOut(locs);
3948 locs->canFreeData = false;
3949 emxFree_real_T(&locs);
3950 peaks->canFreeData = false;
3951 emxFree_real_T(&peaks);
3952 emlrtHeapReferenceStackLeaveFcnR2012b(&st);
3953 }
3954
3955 void matlabfindpeaks_atexit(void)
3956 {
3957 emlrtStack st = { NULL, NULL, NULL };
3958
3959 mexFunctionCreateRootTLS();
3960 st.tls = emlrtRootTLSGlobal;
3961 emlrtEnterRtStackR2012b(&st);
3962
3963 /* Free instance data */
3964 covrtFreeInstanceData(&emlrtCoverageInstance);
3965 emlrtLeaveRtStackR2012b(&st);
3966 emlrtDestroyRootTLS(&emlrtRootTLSGlobal);
3967 }
3968
3969 void matlabfindpeaks_initialize(void)
3970 {
3971 emlrtStack st = { NULL, NULL, NULL };
3972
3973 mexFunctionCreateRootTLS();
3974 emlrtBreakCheckR2012bFlagVar = emlrtGetBreakCheckFlagAddressR2012b();
3975 st.tls = emlrtRootTLSGlobal;
3976 emlrtClearAllocCountR2012b(&st, false, 0U, 0);
3977 emlrtEnterRtStackR2012b(&st);
3978 if (emlrtFirstTimeR2012b(emlrtRootTLSGlobal)) {
3979 matlabfindpeaks_once();
3980 }
3981 }
3982
3983 void matlabfindpeaks_terminate(void)
3984 {
3985 emlrtStack st = { NULL, NULL, NULL };
3986
3987 st.tls = emlrtRootTLSGlobal;
3988 emlrtLeaveRtStackR2012b(&st);
3989 emlrtDestroyRootTLS(&emlrtRootTLSGlobal);
3990 }
3991
3992 /* End of code generation (matlabfindpeaks.c) */
3993
|